Beispiel #1
0
        /**
         * Normalize this quaternion if it is large enough.
         * If it is too small, returns an identity quaternion.
         *
         * @param Tolerance Minimum squared length of quaternion for normalization.
         */
        public void Normalize(float Tolerance = Const.SMALL_NUMBER)
        {
            float SquareSum = X * X + Y * Y + Z * Z + W * W;

            if (SquareSum >= Tolerance)
            {
                float Scale = FMath.InvSqrt(SquareSum);

                X *= Scale;
                Y *= Scale;
                Z *= Scale;
                W *= Scale;
            }
            else
            {
                this = FQuat.Identity;
            }
        }