scipy Rotation.适用于什么?

4xrmg8kj  于 8个月前  发布在  其他
关注(0)|答案(1)|浏览(86)

以下问题:
我有

  • 3x3旋转矩阵R,其描述以下之间的旋转:
  • 我的Nx3积分A
  • 我的Nx3积分B

现在我想将点A变换为B。
现在使用scipy Rotation apply,我得到了一个与手工操作不同的解决方案:

import numpy as np
from scipy.spatial.transform import Rotation

# With scipy
R_scipy = Rotation.from_dcm(R)
B_scipy = R_scipy.apply(A)

# By hand
B_hand = (R.dot(A.T)).T

# B_scipy != B_hand

为什么会这样?我是不是漏了什么?

gg0vcinb

gg0vcinb1#

@hpaulj是正确的。下面是一个最小的可重复示例,显示结果在元素方面等于公差:

import numpy as np
from scipy.spatial.transform import Rotation

# Create a random rotation matrix and a random set of points
np.random.seed(0)
R = Rotation.random().as_matrix()
A = np.random.rand(10, 3)

# With scipy
R_scipy = Rotation.from_matrix(R)
B_scipy = R_scipy.apply(A)

# By hand
B_hand = (R.dot(A.T)).T

# B_scipy == B_hand?
print(np.allclose(B_scipy, B_hand)) # Outputs: True

相关问题