Exemplo n.º 1
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 IntVector2 vec, out IntVector2 result)
        {
            float scale = MathDefs.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y);

            result.X = (int)Math.Round(vec.X * scale);
            result.Y = (int)Math.Round(vec.Y * scale);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Scales the IntVector2 to approximately unit length.
        /// </summary>
        public void NormalizeFast()
        {
            float scale = MathDefs.InverseSqrtFast(X * X + Y * Y);

            X = (int)Math.Round(X * scale);
            Y = (int)Math.Round(Y * scale);
        }
Exemplo n.º 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 Vector2 vec, out Vector2 result)
        {
            float scale = MathDefs.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y);

            result.X = vec.X * scale;
            result.Y = vec.Y * scale;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Scales the Vector2 to approximately unit length.
        /// </summary>
        public void NormalizeFast()
        {
            float scale = MathDefs.InverseSqrtFast(X * X + Y * Y);

            X *= scale;
            Y *= scale;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Scale a vector to approximately unit length
        /// </summary>
        /// <param name="vec">The input vector</param>
        /// <returns>The normalized vector</returns>
        public static IntVector2 NormalizeFast(IntVector2 vec)
        {
            float scale = MathDefs.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y);

            vec.X = (int)Math.Round(vec.X * scale);
            vec.Y = (int)Math.Round(vec.Y * scale);
            return(vec);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Scale a vector to approximately unit length
        /// </summary>
        /// <param name="vec">The input vector</param>
        /// <returns>The normalized vector</returns>
        public static Vector2 NormalizeFast(Vector2 vec)
        {
            float scale = MathDefs.InverseSqrtFast(vec.X * vec.X + vec.Y * vec.Y);

            vec.X *= scale;
            vec.Y *= scale;
            return(vec);
        }