Example #1
0
        public static OrientationRotation IsForwardBackWardRightLeft(Vector3 forwardDir,
                                                                     Vector3 toGoDir, Vector3 relativeUp)
        {
            float dotDir = Vector3.Dot(forwardDir, toGoDir);
            float right  = 0f;
            float left   = 0f;
            int   irol   = ExtVector3.IsRightOrLeft(forwardDir, relativeUp, toGoDir, ref left, ref right);

            if (dotDir > 0)
            {
                if (irol == 1)
                {
                    return(OrientationRotation.FORWARD_AND_RIGHT);
                }
                else if (irol == -1)
                {
                    return(OrientationRotation.FORWARD_AND_LEFT);
                }
            }
            else if (dotDir < 0)
            {
                if (irol == 1)
                {
                    return(OrientationRotation.BEHIND_AND_RIGHT);
                }
                else if (irol == -1)
                {
                    return(OrientationRotation.BEHIND_AND_LEFT);
                }
            }
            return(OrientationRotation.NONE);
        }
Example #2
0
 public static float MagnitudeInDirection(Vector3 vector, Vector3 direction, bool normalizeParameters = true)
 {
     if (normalizeParameters)
     {
         direction.Normalize();
     }
     return(ExtVector3.DotProduct(vector, direction));
 }
Example #3
0
 private static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime)
 {
     target = current + DeltaAngle(current, target);
     return(ExtVector3.OwnSmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime));
 }
Example #4
0
 /// <summary>
 /// Returns a rotation of up attempting to face in the general direction of forward.
 /// </summary>
 /// <param name="up"></param>
 /// <param name="targForward"></param>
 /// <returns></returns>
 public static Quaternion FaceRotation(Vector3 forward, Vector3 up)
 {
     forward = ExtVector3.GetForwardTangent(forward, up);
     return(Quaternion.LookRotation(forward, up));
 }