Fractrace.Geometry.VecRotation.Normalize C# (CSharp) Method

Normalize() public method

public Normalize ( ) : void
return void
        public void Normalize()
        {
            double r = Math.Sqrt(X * X + Y * Y + Z * Z);
            if (r != 0)
            {
                X = X / r;
                Y = Y / r;
                Z = Z / r;
            }
        }

Usage Example

Esempio n. 1
0
        void RotateZ(double angle)
        {
            Fractrace.Geometry.VecRotation rotation = new VecRotation();
            rotation.FromEuler(Math.PI * ParameterDict.Current.GetDouble("Transformation.Camera.AngleX") / 180.0,
                Math.PI * ParameterDict.Current.GetDouble("Transformation.Camera.AngleY") / 180.0,
                Math.PI * ParameterDict.Current.GetDouble("Transformation.Camera.AngleZ") / 180.0);

            rotation.Normalize();
            rotation.combine(0, 0, angle);

            double ax = 0, ay = 0, az = 0;
            rotation.toEuler(ref ax, ref ay, ref az);

            ax = 180 * ax / Math.PI;
            ay = 180 * ay / Math.PI;
            az = 180 * az / Math.PI;

            ParameterDict.Current.SetDouble("Transformation.Camera.AngleX", ax);
            ParameterDict.Current.SetDouble("Transformation.Camera.AngleY", ay);
            ParameterDict.Current.SetDouble("Transformation.Camera.AngleZ", az);
        }