Canguro.Analysis.ExtrudedShape.checkIntegrity C# (CSharp) Method

checkIntegrity() public static method

Checks if this vector has 'good' values, i.e. components are not very little values.
public static checkIntegrity ( System.Vector3 &vector ) : void
vector System.Vector3 Vector to check. Must be a normalized vector.
return void
        public static void checkIntegrity(ref Vector3 vector)
        {
            float threshold = 0.000001f;
            bool mustRenormalize = false;

            if (Math.Abs(vector.X) < threshold)
            {
                vector.X = 0;
                mustRenormalize = true;
            }
            if (Math.Abs(vector.Y) < threshold)
            {
                vector.Y = 0;
                mustRenormalize = true;
            }
            if (Math.Abs(vector.Z) < threshold)
            {
                vector.Z = 0;
                mustRenormalize = true;
            }

            if( mustRenormalize )
                vector.Normalize();

            if (Math.Abs(vector.X) > 0.999999)
                vector.X = Math.Sign(vector.X);

            if (Math.Abs(vector.Y) > 0.999999)
                vector.Y = Math.Sign(vector.Y);

            if (Math.Abs(vector.Z) > 0.999999)
                vector.Z = Math.Sign(vector.Z);
        }