来自旋转矩阵的3D旋转矩阵

时间:2019-03-10 23:10:01

标签: python matrix scipy rotation affinetransform

我有一个需要坐标系( x y z )的矩阵(称为T)旋转为新的坐标系( a b c )。根据{{​​3}}的来源,旋转矩阵R可以在笛卡尔空间中定义如下:

R = [[ax, bx, cx],
     [ay, by, cy],
     [az, bz, cz]]

我想在python的原始矩阵T上实现旋转,这给了我新的图像。 T的索引( z y x )以及numpy中的所有矩阵。到目前为止,我的策略是执行以下操作:

from scipy.ndimage import rotate as sp_rotate

# Get the rotation angles in each axis
theta_y = math.asin(R[0, 2])
theta_z = math.acos(R[0, 0] / math.cos(theta_y))
theta_x = math.acos(R[2, 2] / math.cos(theta_y))

# Convert them to degrees
theta_y = math.degrees(theta_y)
theta_z = math.degrees(theta_z)
theta_x = math.degrees(theta_x)

# Rotate along each axis
T = sp_rotate(T, -theta_x, axes=(0, 1), reshape=False, mode='reflect')
T = sp_rotate(T, -theta_y, axes=(0, 2), reshape=False, mode='reflect')
T = sp_rotate(T, -theta_z, axes=(1, 2), reshape=False, mode='reflect')

是否有一种方法可以根据旋转矩阵R在python中定义旋转,而无需沿每个轴分别进行三个单独的旋转?

0 个答案:

没有答案
相关问题