Skip to content

CoordinateSystem wrong matrix transformation for pitch angle==90 degrees #247

Description

@ebortoluzzi

when the pitch angle is == 90 degrees the cos(pitch)=0.0 and the the elements of the rotation matrix [0,0] and [1,0] shall be 0.0,
[0,0] = cos(pitch)*cos(yaw)
[1,0) = cos(pitch)*sin(yaw)

which is a special case see
Euler Angle Formulas
David Eberly, Geometric Tools, Redmond WA 98052
https://www.geometrictools.com/
2.6 Factor as RzRyRx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pag 9
case

however I tried your formula with bad results
pt1 = new double[3] { 3, 1, 2 };
.....
// Define your angles
Angle yaw = Angle.FromDegrees(30); // Around Z
Angle pitch = Angle.FromDegrees(90); // Around Y
Angle roll = Angle.FromDegrees(60); // Around X

  // Create the rotated coordinate system ZYX
  coordSys = new CoordinateSystem().RotateNoReset(yaw,pitch,roll);
  coordSys = coordSys.SetTranslation(new Vector3D(pt1[0], pt1[1], pt1[2]));

  var coordSys2 = new CoordinateSystem();
  coordSys2 = coordSys2.RotateCoordSysAroundVector(coordSys.ZAxis.Normalize(), yaw);
  coordSys2 = coordSys2.RotateCoordSysAroundVector(coordSys.YAxis.Normalize(), pitch);
  coordSys2 = coordSys2.RotateCoordSysAroundVector(coordSys.XAxis.Normalize(), roll);
  coordSys2 = coordSys2.SetTranslation(new Vector3D(pt1[0], pt1[1], pt1[2]));

both return a rotation matrix with [1,0]<>0.0
5.30288E-17 0 1
1 2.22045E-16 -5.30288E-17
-2.22045E-16 1 0

while the correct one shall be
5.30288E-17 0.5 0.866025
3.06162E-17 0.866025 -0.5
-1 5.30288E-17 3.06162E-17

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions