Last active
November 22, 2018 08:45
-
-
Save MiaoDX/93101bdbc665669085f558529ee078a6 to your computer and use it in GitHub Desktop.
Transform various rotation sequences to YXZ (UnrealCV format), so the rotation sequence matters.
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
""" | |
Transform various rotation sequences to YXZ (UnrealCV format), so the rotation sequence matters. | |
""" | |
import transforms3d | |
import math | |
if __name__ == '__main__': | |
# pitch, yaw, roll = 10, 20, 30 | |
x, y, z = 10, 20, 30 | |
# x, y, z = 90, 45, -90 | |
x=math.radians(x) | |
y=math.radians(y) | |
z=math.radians(z) | |
# M1 = transforms3d.euler.euler2mat(x, y, z, axes='rxyz') | |
# M1 = transforms3d.euler.euler2mat(x, z, y, axes='rxzy') | |
# M1 = transforms3d.euler.euler2mat(y, x, z, axes='ryxz') | |
# M1 = transforms3d.euler.euler2mat(y, z, x, axes='ryzx') | |
# M1 = transforms3d.euler.euler2mat(z, x, y, axes='rzxy') | |
M1 = transforms3d.euler.euler2mat(z, y, x, axes='rzyx') | |
print(M1) | |
rad = transforms3d.euler.mat2euler(M1, 'ryxz') | |
degree = list(map(math.degrees, rad)) | |
print(degree) | |
# to yxz | |
# xyz 20.28 9.39 33.45 | |
# xzy 17.23 -0.30 31.47 | |
# yxz 20.0 10.0 30.0 | |
# yzx 25.04 8.65 30.38 | |
# zxy 22.21 -1.70 31.43 | |
# zyx 22.25 -1.03 28.02 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment