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

combine() public method

calculate total rotation by taking current rotation and then apply rotation r if both angles are quaternions then this is a multiplication
public combine ( VecRotation r ) : void
r VecRotation
return void
        public void combine(VecRotation r)
        {
            toQuaternion();
            if (r == null) return;
            double qax = X;
            double qay = Y;
            double qaz = Z;
            double qaw = Angle;

            double s = Math.Sin(r.Angle / 2);
            double qbx = r.X * s;
            double qby = r.Y * s;
            double qbz = r.Z * s;
            double qbw = Math.Cos(r.Angle / 2);

            // now multiply the quaternions
            Angle = (double)(qaw * qbw - qax * qbx - qay * qby - qaz * qbz);
            X = (double)(qax * qbw + qaw * qbx + qay * qbz - qaz * qby);
            Y = (double)(qaw * qby - qax * qbz + qay * qbw + qaz * qbx);
            Z = (double)(qaw * qbz + qax * qby - qay * qbx + qaz * qbw);
            toAxisAngle();
        }

Same methods

VecRotation::combine ( double heading, double attitude, double bank ) : void

Usage Example

Exemplo 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);
        }