示例#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);
        }
示例#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);
        }
        /// <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;
        }
        /// <summary>
        /// Scales the Vector2 to approximately unit length.
        /// </summary>
        public void NormalizeFast()
        {
            float scale = MathDefs.InverseSqrtFast(X * X + Y * Y);

            X *= scale;
            Y *= scale;
        }
示例#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);
        }
        /// <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);
        }