简体   繁体   中英

Given a set of Euler Angles, (Pitch, Yaw, Roll) how to find alternate set that describes same 3D orientation?

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.

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 (ie 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM