问题
I have a nice quaternion to euler equation that is sometimes returning a non-intuitive set of angles.
For example:
- Pitch: 129
- Yaw: -85
- Roll: 126
I would like to programatically find alternate rotations such that Pitch and Roll are between -90 and 90. Yaw can be 0 to 360.
[EDIT] Pitch is constrained to -90 to +90 and Roll is constrained to -180 to +180.
回答1:
Basically, you want to prevent the orientation to go beyond the pole. It is very easy to do that:
First, check if pitch is beyond the pole (i.e. greater than 90° or smaller than -90°). In that case, do the following:
add 180° to yaw
add 180° to roll
set new pitch to 180° - old pitch (or -180° - old pitch in the case of south pole)
This is basically all. You can also adapt the new angles as follows:
while(yaw < 0)
yaw += 360
while(yaw > 360)
yaw -= 360
while(roll < -180)
roll += 360
while(roll > 180)
roll -= 360
来源:https://stackoverflow.com/questions/37146033/given-a-set-of-euler-angles-pitch-yaw-roll-how-to-find-alternate-set-that-d