Exemplo n.º 1
0
        public static Vector3Double SmoothDamp(Vector3Double current, Vector3Double target, ref Vector3Double currentVelocity, double smoothTime)
        {
            double deltaTime = (double)Time.deltaTime;
            double maxSpeed  = double.PositiveInfinity;

            return(Vector3Double.SmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime));
        }
Exemplo n.º 2
0
        public static void OrthoNormalize(ref Vector3Double normal, ref Vector3Double tangent)
        {
            Vector3 v3normal  = new Vector3();
            Vector3 v3tangent = new Vector3();

            v3normal  = (Vector3)normal;
            v3tangent = (Vector3)tangent;
            Vector3.OrthoNormalize(ref v3normal, ref v3tangent);
            normal  = new Vector3Double(v3normal);
            tangent = new Vector3Double(v3tangent);
        }
Exemplo n.º 3
0
 public static Vector3Double ClampMagnitude(Vector3Double vector, double maxLength)
 {
     if (vector.sqrMagnitude > maxLength * maxLength)
     {
         return(vector.normalized * maxLength);
     }
     else
     {
         return(vector);
     }
 }
Exemplo n.º 4
0
        public void Normalize()
        {
            double num = Vector3Double.Magnitude(this);

            if (num > 9.99999974737875E-06)
            {
                this = this / num;
            }
            else
            {
                this = Vector3Double.zero;
            }
        }
Exemplo n.º 5
0
        public static Vector3Double Project(Vector3Double vector, Vector3Double onNormal)
        {
            double num = Vector3Double.Dot(onNormal, onNormal);

            if (num < 1.40129846432482E-45d)
            {
                return(Vector3Double.zero);
            }
            else
            {
                return(onNormal * Vector3Double.Dot(vector, onNormal) / num);
            }
        }
Exemplo n.º 6
0
        public static Vector3Double Normalize(Vector3Double value)
        {
            double num = Vector3Double.Magnitude(value);

            if (num > 9.99999974737875E-06)
            {
                return(value / num);
            }
            else
            {
                return(Vector3Double.zero);
            }
        }
Exemplo n.º 7
0
        public static Vector3Double MoveTowards(Vector3Double current, Vector3Double target, double maxDistanceDelta)
        {
            Vector3Double vector3   = target - current;
            double        magnitude = vector3.magnitude;

            if (magnitude <= maxDistanceDelta || magnitude == 0.0d)
            {
                return(target);
            }
            else
            {
                return(current + vector3 / magnitude * maxDistanceDelta);
            }
        }
Exemplo n.º 8
0
        public override bool Equals(object other)
        {
            if (!(other is Vector3Double))
            {
                return(false);
            }
            Vector3Double vector3d = (Vector3Double)other;

            if (this.x.Equals(vector3d.x) && this.y.Equals(vector3d.y))
            {
                return(this.z.Equals(vector3d.z));
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 9
0
        public static Vector3Double SmoothDamp(Vector3Double current, Vector3Double target, ref Vector3Double currentVelocity, double smoothTime, double maxSpeed, double deltaTime)
        {
            smoothTime = Mathd.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));
            Vector3Double vector    = current - target;
            Vector3Double vector3_1 = target;
            double        maxLength = maxSpeed * smoothTime;
            Vector3Double vector3_2 = Vector3Double.ClampMagnitude(vector, maxLength);

            target = current - vector3_2;
            Vector3Double vector3_3 = (currentVelocity + num1 * vector3_2) * deltaTime;

            currentVelocity = (currentVelocity - num1 * vector3_3) * num3;
            Vector3Double vector3_4 = target + (vector3_2 + vector3_3) * num3;

            if (Vector3Double.Dot(vector3_1 - current, vector3_4 - vector3_1) > 0.0)
            {
                vector3_4       = vector3_1;
                currentVelocity = (vector3_4 - vector3_1) / deltaTime;
            }
            return(vector3_4);
        }
Exemplo n.º 10
0
 public static Vector3Double Cross(Vector3Double lhs, Vector3Double rhs)
 {
     return(new Vector3Double(lhs.y * rhs.z - lhs.z * rhs.y, lhs.z * rhs.x - lhs.x * rhs.z, lhs.x * rhs.y - lhs.y * rhs.x));
 }
Exemplo n.º 11
0
        public static double Distance(Vector3Double a, Vector3Double b)
        {
            Vector3Double vector3d = new Vector3Double(a.x - b.x, a.y - b.y, a.z - b.z);

            return(Math.Sqrt(vector3d.x * vector3d.x + vector3d.y * vector3d.y + vector3d.z * vector3d.z));
        }
Exemplo n.º 12
0
 public static Vector3Double Exclude(Vector3Double excludeThis, Vector3Double fromThat)
 {
     return(fromThat - Vector3Double.Project(fromThat, excludeThis));
 }
Exemplo n.º 13
0
        public static Vector3Double Slerp(Vector3Double from, Vector3Double to, double t)
        {
            Vector3 v3 = Vector3.Slerp((Vector3)from, (Vector3)to, (float)t);

            return(new Vector3Double(v3));
        }
Exemplo n.º 14
0
 public static double Dot(Vector3Double lhs, Vector3Double rhs)
 {
     return(lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z);
 }
Exemplo n.º 15
0
        public static Vector3Double RotateTowards(Vector3Double current, Vector3Double target, double maxRadiansDelta, double maxMagnitudeDelta)
        {
            Vector3 v3 = Vector3.RotateTowards((Vector3)current, (Vector3)target, (float)maxRadiansDelta, (float)maxMagnitudeDelta);

            return(new Vector3Double(v3));
        }
Exemplo n.º 16
0
 public static Vector3Double Lerp(Vector3Double from, Vector3Double to, double t)
 {
     t = Mathd.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));
 }
Exemplo n.º 17
0
 public static Vector3Double Max(Vector3Double lhs, Vector3Double rhs)
 {
     return(new Vector3Double(Mathd.Max(lhs.x, rhs.x), Mathd.Max(lhs.y, rhs.y), Mathd.Max(lhs.z, rhs.z)));
 }
Exemplo n.º 18
0
 public static double Magnitude(Vector3Double a)
 {
     return(Math.Sqrt(a.x * a.x + a.y * a.y + a.z * a.z));
 }
Exemplo n.º 19
0
 public void Scale(Vector3Double scale)
 {
     this.x *= scale.x;
     this.y *= scale.y;
     this.z *= scale.z;
 }
Exemplo n.º 20
0
 public static Vector3Double Scale(Vector3Double a, Vector3Double b)
 {
     return(new Vector3Double(a.x * b.x, a.y * b.y, a.z * b.z));
 }
Exemplo n.º 21
0
 public static double SqrMagnitude(Vector3Double a)
 {
     return(a.x * a.x + a.y * a.y + a.z * a.z);
 }
Exemplo n.º 22
0
 public static Vector3Double Reflect(Vector3Double inDirection, Vector3Double inNormal)
 {
     return(-2d * Vector3Double.Dot(inNormal, inDirection) * inNormal + inDirection);
 }
Exemplo n.º 23
0
 public static double AngleBetween(Vector3Double from, Vector3Double to)
 {
     return(Mathd.Acos(Mathd.Clamp(Vector3Double.Dot(from.normalized, to.normalized), -1d, 1d)));
 }
Exemplo n.º 24
0
 public static bool operator !=(Vector3Double lhs, Vector3Double rhs)
 {
     return((double)Vector3Double.SqrMagnitude(lhs - rhs) >= 0.0 / 1.0);
 }