Esempio n. 1
0
        /**
         * Returns a normalized copy of the vector if safe to normalize.
         *
         * @param Tolerance Minimum squared length of vector for normalization.
         * @return A normalized copy of the vector or a zero vector.
         */
        public FVector4 GetSafeNormal(float Tolerance = Const.SMALL_NUMBER)
        {
            float SquareSum = X * X + Y * Y + Z * Z;

            if (SquareSum > Tolerance)
            {
                float Scale = FMath.InvSqrt(SquareSum);
                return(new FVector4(X * Scale, Y * Scale, Z * Scale, 0.0f));
            }
            return(new FVector4(0.0f));
        }