Created
November 23, 2018 12:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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