Ejemplo n.º 1
0
 public static double AngleBetween(Vector3d from, Vector3d to)
 {
     return(Mathd.Acos(Mathd.Clamp(Vector3d.Dot(from.normalized, to.normalized), -1d, 1d)));
 }
Ejemplo n.º 2
0
 public static double Angle(Vector3d from, Vector3d to)
 {
     return(Mathd.Acos(Mathd.Clamp(Vector3d.Dot(from.normalized, to.normalized), -1d, 1d)) * 57.29578d);
 }
Ejemplo n.º 3
0
 public static Vector3d ProjectOnPlane(Vector3d vector, Vector3d planeNormal)
 {
     return(vector - planeNormal * Vector3d.Dot(vector, planeNormal));
 }
Ejemplo n.º 4
0
 public static Vector3d Reflect(Vector3d inDirection, Vector3d inNormal)
 {
     return(-2d * Vector3d.Dot(inNormal, inDirection) * inNormal + inDirection);
 }
Ejemplo n.º 5
0
        public static Vector3d RotateTowards(Vector3d current, Vector3d target, double maxRadiansDelta, double maxMagnitudeDelta)
        {
            //Vector3 v3 = Vector3.RotateTowards((Vector3)current, (Vector3)target, (float)maxRadiansDelta, (float)maxMagnitudeDelta);
            //return new Vector3d(v3);
            Vector3d k     = Vector3d.Cross(current, target).normalized;
            Vector3d v     = current;
            double   o     = maxRadiansDelta;
            Vector3d v_rot = v * System.Math.Cos(o) + Vector3d.Cross(k, v) * System.Math.Sin(o) + k * Vector3d.Dot(k, v) * (1.0 - System.Math.Cos(o));

            return(v_rot);
            //Vector3 v3 = Vector3.RotateTowards((Vector3)current, (Vector3)target, (float)maxRadiansDelta, (float)maxMagnitudeDelta);
            //return new Vector3d(v3);
        }