Code: Select all
float pitch = 0;
float yaw = 90;
float roll = 0;
cout << "Pitch = " << pitch << endl;
cout << "Yaw = " << yaw << endl;
cout << "Roll = " << roll << endl;
cout << "--------------------" << endl;
btQuaternion rotation(btRadians(yaw), btRadians(pitch), btRadians(roll));
btVector3 axis = rotation.getAxis();
btScalar angle = rotation.getAngle();
cout << "Axis X = " << axis.x() << endl;
cout << "Axis Y = " << axis.y() << endl;
cout << "Axis Z = " << axis.z() << endl;
cout << "Angle = " << btDegrees(angle) << endl;
cout << "--------------------" << endl;
btMatrix3x3(rotation).getEulerYPR(yaw, pitch, roll);
pitch = btDegrees(pitch);
yaw = btDegrees(yaw);
roll = btDegrees(roll);
cout << "Pitch = " << pitch << endl;
cout << "Yaw = " << yaw << endl;
cout << "Roll = " << roll << endl;
cout << "--------------------" << endl;
rotation = btQuaternion(btRadians(yaw), btRadians(pitch), btRadians(roll));
axis = rotation.getAxis();
angle = rotation.getAngle();
cout << "Axis X = " << axis.x() << endl;
cout << "Axis Y = " << axis.y() << endl;
cout << "Axis Z = " << axis.z() << endl;
cout << "Angle = " << btDegrees(angle) << endl;
cout << "--------------------" << endl;
The first section is as I would expect.Pitch = 0
Yaw = 90
Roll = 0
--------------------
Axis X = 0
Axis Y = 1
Axis Z = 0
Angle = 90
--------------------
Pitch = 90
Yaw = 180
Roll = 180
--------------------
Axis X = 1
Axis Y = 0
Axis Z = 0
Angle = 90
--------------------
The second section is as I would expect.
But the third section seems crazy. It doesn't seem to be an equivalent rotation.