从齐次矩阵确定变换矩阵

时间:2020-09-05 23:18:28

标签: python numpy matrix

我想找到平移矩阵,旋转矩阵以及比例矩阵。以下是我的代码,

import numpy as np

def get_rotation_from_homogeneous_transform(transform):
    
    s = transform.shape
    if s[0] != s[1]:
        raise ValueError('Matrix must be a 4x4 homogenous transformation', s)
    n = s[0]
    rotation = transform[0:n - 1, 0:n - 1]
    return rotation

homogeneous_matrix = np.array([[-0.008189, 0.000428, -0.999900, 0.000000],
[0.758580, 0.651582, 0.008000, 0.000000],
 [0.651582, 0.758580, -0.011300, 0.000000],
  [1.294619, 0.885227, 1.358000, 1.000000]]).astype(np.float32).T

rotM = get_rotation_from_homogeneous_transform(homogeneous_matrix)

我是否正确提取了旋转矩阵?如何提取平移和比例矩阵?

0 个答案:

没有答案