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

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

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

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

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

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

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

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

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

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

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

            return(Math.Sqrt(DVector3.x * DVector3.x + DVector3.y * DVector3.y + DVector3.z * DVector3.z));
        }
Esempio n. 12
0
 public static double Angle(DVector3 from, DVector3 to)
 {
     return(Mathd.Acos(Mathd.Clamp(DVector3.Dot(from.normalized, to.normalized), -1d, 1d)) * 57.29578d);
 }
Esempio n. 13
0
 public static DVector3 Exclude(DVector3 excludeThis, DVector3 fromThat)
 {
     return(fromThat - DVector3.Project(fromThat, excludeThis));
 }
Esempio n. 14
0
        public static DVector3 Slerp(DVector3 from, DVector3 to, double t)
        {
            Vector3 v3 = Vector3.Slerp((Vector3)from, (Vector3)to, (float)t);

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

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