예제 #1
0
 public static Vector2Double ClampMagnitude(Vector2Double vector, double maxLength)
 {
     if (vector.sqrMagnitude > maxLength * maxLength)
     {
         return(vector.normalized * maxLength);
     }
     else
     {
         return(vector);
     }
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
 public static Vector2Double Max(Vector2Double lhs, Vector2Double rhs)
 {
     return(new Vector2Double(Mathd.Max(lhs.x, rhs.x), Mathd.Max(lhs.y, rhs.y)));
 }
예제 #5
0
 public static double SqrMagnitude(Vector2Double a)
 {
     return(a.x * a.x + a.y * a.y);
 }
예제 #6
0
 public static double Distance(Vector2Double a, Vector2Double b)
 {
     return((a - b).magnitude);
 }
예제 #7
0
 public static double Angle(Vector2Double from, Vector2Double to)
 {
     return(Mathd.Acos(Mathd.Clamp(Vector2Double.Dot(from.normalized, to.normalized), -1d, 1d)) * 57.29578d);
 }
예제 #8
0
 public static double Dot(Vector2Double lhs, Vector2Double rhs)
 {
     return(lhs.x * rhs.x + lhs.y * rhs.y);
 }
예제 #9
0
 public void Scale(Vector2Double scale)
 {
     this.x *= scale.x;
     this.y *= scale.y;
 }
예제 #10
0
 public static Vector2Double Scale(Vector2Double a, Vector2Double b)
 {
     return(new Vector2Double(a.x * b.x, a.y * b.y));
 }
예제 #11
0
 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));
 }
예제 #12
0
 public static bool operator !=(Vector2Double lhs, Vector2Double rhs)
 {
     return((double)Vector2Double.SqrMagnitude(lhs - rhs) >= 0.0 / 1.0);
 }
예제 #13
0
 public static bool operator ==(Vector2Double lhs, Vector2Double rhs)
 {
     return(Vector2Double.SqrMagnitude(lhs - rhs) < 0.0 / 1.0);
 }