InverseSqrtFast() 공개 정적인 메소드

Returns an approximation of the inverse square root of left number.
This is an improved implementation of the the method known as Carmack's inverse square root which is found in the Quake III source code. This implementation comes from http://www.codemaestro.com/reviews/review00000105.html. For the history of this method, see http://www.beyond3d.com/content/articles/8/
public static InverseSqrtFast ( double x ) : double
x double A number.
리턴 double
예제 #1
0
        /// <summary>
        /// Scales the Vector4d to approximately unit length.
        /// </summary>
        public void NormalizeFast()
        {
            double scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z + W * W);

            X *= scale;
            Y *= scale;
            Z *= scale;
            W *= scale;
        }
        /// <summary>
        /// Scale a vector to approximately unit length
        /// </summary>
        /// <param name="vec">The input vector</param>
        /// <returns>The normalized vector</returns>
        public static Vector3 NormalizeFast(Vector3 vec)
        {
            float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z);

            vec.X *= scale;
            vec.Y *= scale;
            vec.Z *= scale;
            return(vec);
        }
예제 #3
0
        /// <summary>
        /// Scale a vector to approximately unit length
        /// </summary>
        /// <param name="vec">The input vector</param>
        /// <param name="result">The normalized vector</param>
        public static void NormalizeFast(ref Vector4 vec, out Vector4 result)
        {
            float scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W);

            result.X = vec.X * scale;
            result.Y = vec.Y * scale;
            result.Z = vec.Z * scale;
            result.W = vec.W * scale;
        }
예제 #4
0
파일: Vector4d.cs 프로젝트: conankzhang/fez
        public static void NormalizeFast(ref Vector4d vec, out Vector4d result)
        {
            double num = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W);

            result.X = vec.X * num;
            result.Y = vec.Y * num;
            result.Z = vec.Z * num;
            result.W = vec.W * num;
        }
예제 #5
0
파일: Vector4d.cs 프로젝트: conankzhang/fez
        public void NormalizeFast()
        {
            double num = MathHelper.InverseSqrtFast(this.X * this.X + this.Y * this.Y + this.Z * this.Z + this.W * this.W);

            this.X *= num;
            this.Y *= num;
            this.Z *= num;
            this.W *= num;
        }
예제 #6
0
        public static Vector3 NormalizeFast(Vector3 vec)
        {
            float num = MathHelper.InverseSqrtFast((float)((double)vec.X * (double)vec.X + (double)vec.Y * (double)vec.Y + (double)vec.Z * (double)vec.Z));

            vec.X *= num;
            vec.Y *= num;
            vec.Z *= num;
            return(vec);
        }
예제 #7
0
        public static void NormalizeFast(ref Vector4 vec, out Vector4 result)
        {
            float num = MathHelper.InverseSqrtFast((float)((double)vec.X * (double)vec.X + (double)vec.Y * (double)vec.Y + (double)vec.Z * (double)vec.Z + (double)vec.W * (double)vec.W));

            result.X = vec.X * num;
            result.Y = vec.Y * num;
            result.Z = vec.Z * num;
            result.W = vec.W * num;
        }
예제 #8
0
        public void NormalizeFast()
        {
            float num = MathHelper.InverseSqrtFast((float)((double)this.X * (double)this.X + (double)this.Y * (double)this.Y + (double)this.Z * (double)this.Z + (double)this.W * (double)this.W));

            this.X *= num;
            this.Y *= num;
            this.Z *= num;
            this.W *= num;
        }
예제 #9
0
        /// <summary>
        /// Scale a vector to approximately unit length
        /// </summary>
        /// <param name="vec">The input vector</param>
        /// <returns>The normalized vector</returns>
        public static Vector4d NormalizeFast(Vector4d vec)
        {
            double scale = MathHelper.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z + vec.W * vec.W);

            vec.X *= scale;
            vec.Y *= scale;
            vec.Z *= scale;
            vec.W *= scale;
            return(vec);
        }
예제 #10
0
 public static double InverseSqrtFast(double x)
 {
     return((double)MathHelper.InverseSqrtFast((float)x));
 }