Universe.Physics.PrimMesher.Quat.Normalize C# (CSharp) Method

Normalize() public method

public Normalize ( ) : Quat
return Quat
        public Quat Normalize ()
        {
            const float MAG_THRESHOLD = 0.0000001f;
            float mag = Length ();

            // Catch very small rounding errors when normalizing
            if (mag > MAG_THRESHOLD)
            {
                float oomag = 1f / mag;
                X *= oomag;
                Y *= oomag;
                Z *= oomag;
                W *= oomag;
            } else
            {
                X = 0f;
                Y = 0f;
                Z = 0f;
                W = 1f;
            }

            return this;
        }