public static Vector3d SmoothDamp(Vector3d current, Vector3d target, ref Vector3d currentVelocity, double smoothTime, double maxSpeed, double deltaTime) { smoothTime = CGMath.Max(0.0001d, smoothTime); double num1 = 2d / smoothTime; double num2 = num1 * deltaTime; double num3 = (1.0d / (1.0d + num2 + 0.479999989271164d * num2 * num2 + 0.234999999403954d * num2 * num2 * num2)); Vector3d vector = current - target; Vector3d vector3_1 = target; double maxLength = maxSpeed * smoothTime; Vector3d vector3_2 = Vector3d.ClampMagnitude(vector, maxLength); target = current - vector3_2; Vector3d vector3_3 = (currentVelocity + num1 * vector3_2) * deltaTime; currentVelocity = (currentVelocity - num1 * vector3_3) * num3; Vector3d vector3_4 = target + (vector3_2 + vector3_3) * num3; if (!(Vector3d.Dot(vector3_1 - current, vector3_4 - vector3_1) > 0.0)) { return(vector3_4); } vector3_4 = vector3_1; currentVelocity = (vector3_4 - vector3_1) / deltaTime; return(vector3_4); }
public static Vector2d Max(Vector2d lhs, Vector2d rhs) { return(new Vector2d(CGMath.Max(lhs.x, rhs.x), CGMath.Max(lhs.y, rhs.y))); }
public static double Angle(Vector2d from, Vector2d to) { return(CGMath.Acos(CGMath.Clamp(Vector2d.Dot(from.normalized, to.normalized), -1d, 1d)) * 57.29578d); }
public static Vector2d Lerp(Vector2d from, Vector2d to, double t) { t = CGMath.Clamp01(t); return(new Vector2d(from.x + (to.x - from.x) * t, from.y + (to.y - from.y) * t)); }
public static Vector3d Max(Vector3d lhs, Vector3d rhs) { return(new Vector3d(CGMath.Max(lhs.x, rhs.x), CGMath.Max(lhs.y, rhs.y), CGMath.Max(lhs.z, rhs.z))); }
public static Vector2Double Max(Vector2Double lhs, Vector2Double rhs) { return(new Vector2Double(CGMath.Max(lhs.x, rhs.x), CGMath.Max(lhs.y, rhs.y))); }
public static Vector3Double Min(Vector3Double lhs, Vector3Double rhs) { return(new Vector3Double(CGMath.Min(lhs.x, rhs.x), CGMath.Min(lhs.y, rhs.y), CGMath.Min(lhs.z, rhs.z))); }
public static Vector3Double Lerp(Vector3Double from, Vector3Double to, double t) { t = CGMath.Clamp01(t); return(new Vector3Double(from.x + (to.x - from.x) * t, from.y + (to.y - from.y) * t, from.z + (to.z - from.z) * t)); }