Applying Yaw, Pitch, and Roll

Look! there's a flower!·2024년 8월 31일

Basic rules

  1. Extrinsic rotations (fixed axes)-rotate around fixed axis
  • Yaw: rotate around original z-axis
  • Pitch: rotate around original y-axis
  • Roll: rotate around original x-axis
  1. Intrinsic rotations (moving axes)-rotate each axes moved
  • Yaw: rotate around original z-axis
  • Pitch: rotate around new y-axis(after Yaw has been applied)
  • Roll: rotate around new x-axis(after Yaw and Pitch has been applied)

Intrinsic cases using HelixToolkit

  1. creating transformation

    
    using System.Windows.Media.Media3D;
    using HelixToolkit.Wpf;
    public Matrix3D CalculateAttitudeMatrix(double yaw, double pitch, double roll)
    {
        // Convert angles to radians
        double yawRad = yaw * Math.PI / 180.0;
        double pitchRad = pitch * Math.PI / 180.0;
        double rollRad = roll * Math.PI / 180.0;
    
        // Create rotation matrices
        var yawRotation = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), yaw)).Value;
        var pitchRotation = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), pitch)).Value;
        var rollRotation = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), roll)).Value;
    
        // Combine rotations (order matters: first yaw, then pitch, then roll)
        return rollRotation * pitchRotation * yawRotation;
    }
      
  2. applying

    Matrix3D attitudeMatrix = CalculateAttitudeMatrix(yaw, pitch, roll);
    // Apply the transformation to your model
    yourModel.Transform = new MatrixTransform3D(attitudeMatrix);
    
profile
Why don't you take a look around for a moment?

0개의 댓글