Example #1
0
        public static TSQuaternion LerpUnclamped(TSQuaternion a, TSQuaternion b, FP t)
        {
            TSQuaternion result = TSQuaternion.Multiply(a, (1 - t)) + TSQuaternion.Multiply(b, t);

            result.Normalize();

            return(result);
        }
Example #2
0
        public static TSQuaternion FromToRotation(TSVector fromVector, TSVector toVector)
        {
            TSVector     w = TSVector.Cross(fromVector, toVector);
            TSQuaternion q = new TSQuaternion(w.x, w.y, w.z, TSVector.Dot(fromVector, toVector));

            q.w += FP.Sqrt(fromVector.sqrMagnitude * toVector.sqrMagnitude);
            q.Normalize();

            return(q);
        }
Example #3
0
        /**
         *  @brief Rotates game object based on provided axis angles and relative space.
         *
         *  If relative space is SELF then the game object will rotate based on its forward vector.
         **/
        public void Rotate(TSVector eulerAngles, Space relativeTo)
        {
            TSQuaternion result = TSQuaternion.identity;

            if (relativeTo == Space.Self)
            {
                result = this.rotation * TSQuaternion.Euler(eulerAngles);
            }
            else
            {
                result = TSQuaternion.Euler(eulerAngles) * this.rotation;
            }

            result.Normalize();
            this.rotation = result;
        }
Example #4
0
        /**
         *  @brief Rotates game object based on provided axis, angle of rotation and relative space.
         *
         *  If relative space is SELF then the game object will rotate based on its forward vector.
         **/
        public void Rotate(TSVector axis, FP angle, Space relativeTo)
        {
            TSQuaternion result = TSQuaternion.identity;

            if (relativeTo == Space.Self)
            {
                result = this.rotation * TSQuaternion.AngleAxis(angle, axis);
            }
            else
            {
                result = TSQuaternion.AngleAxis(angle, axis) * this.rotation;
            }

            result.Normalize();
            this.rotation = result;
        }