Skip to content

Instantly share code, notes, and snippets.

@MiaoDX
Created November 23, 2018 12:29
Show Gist options
  • Save MiaoDX/da8ffd4c4ac6556a683317a21e9d2a0f to your computer and use it in GitHub Desktop.
Save MiaoDX/da8ffd4c4ac6556a683317a21e9d2a0f to your computer and use it in GitHub Desktop.
By inverse rotation, or in other world, rotate camera from world origin and rotate back, will have completely different angles, if the sequence are maintained.
"""
Rotation inverse & different sequence.
By inverse rotation, or in other world, rotate camera from world origin and rotate back, will have completely different angles, if the sequence are maintained.
"""
import transforms3d
import math
if __name__ == '__main__':
pitch, yaw, roll = 10, 20, 30
# x, y, z = 0, 90, 0
x=math.radians(pitch)
y=math.radians(yaw)
z=math.radians(roll)
R_w2c = transforms3d.euler.euler2mat(x, y, z, axes='rxyz')
R_c2w = R_w2c.T
xyz_rad = transforms3d.euler.mat2euler(R_c2w, axes='rxyz')
xyz_degree = list(map(math.degrees, xyz_rad))
print(xyz_degree) # (-19.01, -11.82, -33.75)
zyx_rad = transforms3d.euler.mat2euler(R_c2w, axes='rzyx')
zyx_degree = list(map(math.degrees, zyx_rad))
print(zyx_degree) # (-30, -20, -10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment