Esempio n. 1
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. 2
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. 3
0
 public static double AngleBetween(DVector3 from, DVector3 to)
 {
     return(Mathd.Acos(Mathd.Clamp(DVector3.Dot(from.normalized, to.normalized), -1d, 1d)));
 }
Esempio n. 4
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. 5
0
 public static DVector3 Reflect(DVector3 inDirection, DVector3 inNormal)
 {
     return(-2d * DVector3.Dot(inNormal, inDirection) * inNormal + inDirection);
 }