本文整理汇总了Python中scipy.spatial.transform.Rotation.match_vectors方法的典型用法代码示例。如果您正苦于以下问题:Python Rotation.match_vectors方法的具体用法?Python Rotation.match_vectors怎么用?Python Rotation.match_vectors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.spatial.transform.Rotation
的用法示例。
在下文中一共展示了Rotation.match_vectors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_match_vectors_noise
# 需要导入模块: from scipy.spatial.transform import Rotation [as 别名]
# 或者: from scipy.spatial.transform.Rotation import match_vectors [as 别名]
def test_match_vectors_noise():
np.random.seed(0)
n_vectors = 100
rot = Rotation.from_euler('xyz', np.random.normal(size=3))
vectors = np.random.normal(size=(n_vectors, 3))
result = rot.apply(vectors)
# The paper adds noise as indepedently distributed angular errors
sigma = np.deg2rad(1)
tolerance = 1.5 * sigma
noise = Rotation.from_rotvec(
np.random.normal(
size=(n_vectors, 3),
scale=sigma
)
)
# Attitude errors must preserve norm. Hence apply individual random
# rotations to each vector.
noisy_result = noise.apply(result)
est, cov = Rotation.match_vectors(noisy_result, vectors)
# Use rotation compositions to find out closeness
error_vector = (rot * est.inv()).as_rotvec()
assert_allclose(error_vector[0], 0, atol=tolerance)
assert_allclose(error_vector[1], 0, atol=tolerance)
assert_allclose(error_vector[2], 0, atol=tolerance)
# Check error bounds using covariance matrix
cov *= sigma
assert_allclose(cov[0, 0], 0, atol=tolerance)
assert_allclose(cov[1, 1], 0, atol=tolerance)
assert_allclose(cov[2, 2], 0, atol=tolerance)
示例2: test_match_vectors_no_noise
# 需要导入模块: from scipy.spatial.transform import Rotation [as 别名]
# 或者: from scipy.spatial.transform.Rotation import match_vectors [as 别名]
def test_match_vectors_no_noise():
np.random.seed(0)
c = Rotation.from_quat(np.random.normal(size=4))
b = np.random.normal(size=(5, 3))
a = c.apply(b)
est, cov = Rotation.match_vectors(a, b)
assert_allclose(c.as_quat(), est.as_quat())
示例3: test_match_vectors_no_rotation
# 需要导入模块: from scipy.spatial.transform import Rotation [as 别名]
# 或者: from scipy.spatial.transform.Rotation import match_vectors [as 别名]
def test_match_vectors_no_rotation():
x = np.array([[1, 2, 3], [4, 5, 6]])
y = x.copy()
r, p = Rotation.match_vectors(x, y)
assert_array_almost_equal(r.as_dcm(), np.eye(3))