我有一个任务是检查矩阵是否是旋转矩阵,我编写代码如下:
import numpy as np
def isRotationMatrix(R):
# some code here
# return True or False
R = np.array([
[0, 0, 1],
[1, 0, 0],
[0, 1, 0],
])
print(isRotationMatrix(R)) # Should be True
R = np.array([
[-1, 0, 0],
[0, 1, 0],
[0, 0, 1],
])
print(isRotationMatrix(R)) # Should be False
我不知道如何实现函数isRotationMatrix
。在
我天真的工具,它只适用于3x3矩阵:
^{pr2}$
旋转矩阵是orthonormal matrix,它的行列式应该是1。
我的工具:
我使用this旋转矩阵的定义。旋转矩阵应该满足条件}。这里
M (M^T) = (M^T) M = I
和{M^T
表示M
的转置,I
表示单位矩阵,det(M)
表示矩阵M
的行列式。在您可以使用下面的python代码来检查矩阵是否是旋转矩阵。在
相关问题 更多 >
编程相关推荐