コード例 #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);
 }