/// <summary>
        /// Fast Vector2 normalization with 0.001 threshold error.
        /// </summary>
        /// <returns>Normalized Vector2.</returns>
        public static Vector2 NormalizedFast(this Vector2 v)
        {
            var wrapper = new FloatInt();

            wrapper.Float = v.x * v.x + v.y * v.y;
            wrapper.Int   = 0x5f3759df - (wrapper.Int >> 1);
            v.x          *= wrapper.Float;
            v.y          *= wrapper.Float;
            return(v);
        }
예제 #2
0
파일: Parser.cs 프로젝트: Mijyuoon/KGVM
 int DecNumber(string val)
 {
     if (val.EndsWith("f") || val.EndsWith("F"))
     {
         var Conv = new FloatInt();
         Conv.FVal = Convert.ToSingle(val.TrimEnd('f', 'F'));
         return(Conv.IntVal);
     }
     return(Convert.ToInt32(val));
 }
 /// <summary>
 /// Fast Vector3 normalization with 0.001 threshold error.
 /// </summary>
 /// <returns>Normalized Vector3.</returns>
 public static Vector3 NormalizedFast(this Vector3 v)
 {
     var wrapper = new FloatInt ();
     wrapper.Float = v.x * v.x + v.y * v.y + v.z * v.z;
     wrapper.Int = 0x5f3759df - (wrapper.Int >> 1);
     v.x *= wrapper.Float;
     v.y *= wrapper.Float;
     v.z *= wrapper.Float;
     return v;
 }