假设我的身体在坐标系 A 中具有以下外在方向:
A = [20,30,40] # extrinsic xyz in degrees
以及坐标系 B 中的以下方向:
B = [10, 25, 50]
所以从 A 到 B 的转换是:
T = [-10, -5, 10]
所以:
B = A + T
现在我想用 scipy.Rotation 做同样的事情:
from scipy.spatial.transform import Rotation
A = Rotation.from_euler('xyz' ,[20, 30, 40], degrees=True)
B = Rotation.from_euler('xyz', [10, 25, 50], degrees=True)
T = Rotation.from_euler('xyz', [-10, -5, 10], degrees=True)
result = A * T # This seems to be wrong?
print(result.as_euler('xyz', degrees=True)) # Output: [14.02609598 21.61478378 48.20912092]
我的错误在哪里?我做错了什么。我需要使用 scipy 旋转,因为我也会在四元数上应用欧拉角中给出的相同旋转。
答案 0 :(得分:1)
从 A 到 B 的转换不正确。考虑 3D 中的旋转时需要小心,因为围绕不同轴的旋转不会相互交换。
根据你的理解,下面代码中的T应该是得到对象为[0, 0, 0]。但它没有。
O(ceil(log n)) = O(log n)
但是,如果您颠倒旋转顺序,则会按预期转到 [0, 0, 0]。
A = Rotation.from_euler('xyz' ,[20, 30, 40], degrees=True)
T = Rotation.from_euler('xyz', [-20, -30, -40], degrees=True)
result = A * T
print(result.as_euler('xyz', degrees=True))
# output: [-25.4441408 5.14593816 -4.1802616 ]
从 A 到 B 的正确转换是 A = Rotation.from_euler('xyz' ,[20, 30, 40], degrees=True)
T = Rotation.from_euler('zyx', [-40, -30, -20], degrees=True)
result = A * T
print(result.as_euler('xyz', degrees=True))
# output: [ 4.77083202e-15 0.00000000e+00 -1.98784668e-15] practically [0,0,0]
。请参阅以下内容。
T = [-14.74053552, -1.237896, 10.10094351]