public static Vector2Double ClampMagnitude(Vector2Double vector, double maxLength) { if (vector.sqrMagnitude > maxLength * maxLength) { return(vector.normalized * maxLength); } else { return(vector); } }
public static Vector2Double MoveTowards(Vector2Double current, Vector2Double target, double maxDistanceDelta) { Vector2Double vector2 = target - current; double magnitude = vector2.magnitude; if (magnitude <= maxDistanceDelta || magnitude == 0.0d) { return(target); } else { return(current + vector2 / magnitude * maxDistanceDelta); } }
public override bool Equals(object other) { if (!(other is Vector2Double)) { return(false); } Vector2Double vector2d = (Vector2Double)other; if (this.x.Equals(vector2d.x)) { return(this.y.Equals(vector2d.y)); } else { return(false); } }
public static Vector2Double Max(Vector2Double lhs, Vector2Double rhs) { return(new Vector2Double(Mathd.Max(lhs.x, rhs.x), Mathd.Max(lhs.y, rhs.y))); }
public static double SqrMagnitude(Vector2Double a) { return(a.x * a.x + a.y * a.y); }
public static double Distance(Vector2Double a, Vector2Double b) { return((a - b).magnitude); }
public static double Angle(Vector2Double from, Vector2Double to) { return(Mathd.Acos(Mathd.Clamp(Vector2Double.Dot(from.normalized, to.normalized), -1d, 1d)) * 57.29578d); }
public static double Dot(Vector2Double lhs, Vector2Double rhs) { return(lhs.x * rhs.x + lhs.y * rhs.y); }
public void Scale(Vector2Double scale) { this.x *= scale.x; this.y *= scale.y; }
public static Vector2Double Scale(Vector2Double a, Vector2Double b) { return(new Vector2Double(a.x * b.x, a.y * b.y)); }
public static Vector2Double Lerp(Vector2Double from, Vector2Double to, double t) { t = Mathd.Clamp01(t); return(new Vector2Double(from.x + (to.x - from.x) * t, from.y + (to.y - from.y) * t)); }
public static bool operator !=(Vector2Double lhs, Vector2Double rhs) { return((double)Vector2Double.SqrMagnitude(lhs - rhs) >= 0.0 / 1.0); }
public static bool operator ==(Vector2Double lhs, Vector2Double rhs) { return(Vector2Double.SqrMagnitude(lhs - rhs) < 0.0 / 1.0); }