Normalize() public method

public Normalize ( ) : void
return void
Exemplo n.º 1
0
 public void Normalize_Vec3_LengthIsEqualToOne()
 {
     Vec3 v = new Vec3(26, 23, 135);
     v.Normalize();
     Assert.IsTrue(v.Length == 1);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Determines the closest point between a <see cref="CryEngine.BoundingSphere"/> and a <see cref="CryEngine.BoundingSphere"/>.
        /// </summary>
        /// <param name="sphere1">The first sphere to test.</param>
        /// <param name="sphere2">The second sphere to test.</param>
        /// <param name="result">When the method completes, contains the closest point between the two objects;
        /// or, if the point is directly in the center of the sphere, contains <see cref="CryEngine.Vec3"/>.</param>
        /// <remarks>
        /// If the two spheres are overlapping, but not directly ontop of each other, the closest point
        /// is the 'closest' point of intersection. This can also be considered is the deepest point of
        /// intersection.
        /// </remarks>
        public static void ClosestPointSphereSphere(ref BoundingSphere sphere1, ref BoundingSphere sphere2, out Vec3 result)
        {
            // Source: Jorgy343
            // Reference: None

            // Get the unit direction from the first sphere's center to the second sphere's center.
            result = sphere2.Center - sphere1.Center;
            result.Normalize();

            // Multiply the unit direction by the first sphere's radius to get a vector
            // the length of the first sphere.
            result *= sphere1.Radius;

            // Add the first sphere's center to the direction to get a point on the first sphere.
            result += sphere1.Center;
        }