Exemplo n.º 1
0
        /// <summary>
        /// Converts the quaternion into a unit quaternion.
        /// </summary>
        public float Normalise()
        {
            float length = Length();

            if (!Math.IsZero(length))
            {
                float inverse = 1.0f / length;
                X *= inverse;
                Y *= inverse;
                Z *= inverse;
                W *= inverse;
            }
            return(length);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Turns the current vector into a unit vector.
        /// </summary>
        /// <remarks>
        /// The result is a vector one unit in length pointing in the same direction as the original vector.
        /// </remarks>
        public float Normalise()
        {
            float length = Length;

            if (!Math.IsZero(length))
            {
                float inv = 1.0f / length;
                X *= inv;
                Y *= inv;
                Z *= inv;
            }

            return(length);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Converts the quaternion into a unit quaternion.
        /// </summary>
        /// <returns>Normalized quaternion.</returns>
        public Quaternion Normalized()
        {
            Quaternion result = new Quaternion(w, x, y, z);
            float      length = Length();

            if (!Math.IsZero(length))
            {
                float inverse = 1.0f / length;
                result.X *= inverse;
                result.Y *= inverse;
                result.Z *= inverse;
                result.W *= inverse;
            }
            return(result);
        }