当前位置: 首页>>代码示例>>Python>>正文


Python Rotation.from_rotvec方法代码示例

本文整理汇总了Python中scipy.spatial.transform.Rotation.from_rotvec方法的典型用法代码示例。如果您正苦于以下问题:Python Rotation.from_rotvec方法的具体用法?Python Rotation.from_rotvec怎么用?Python Rotation.from_rotvec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.spatial.transform.Rotation的用法示例。


在下文中一共展示了Rotation.from_rotvec方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_match_vectors_noise

# 需要导入模块: from scipy.spatial.transform import Rotation [as 别名]
# 或者: from scipy.spatial.transform.Rotation import from_rotvec [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)
开发者ID:ElDeveloper,项目名称:scipy,代码行数:36,代码来源:test_rotation.py

示例2: test_rotvec_calc_pipeline

# 需要导入模块: from scipy.spatial.transform import Rotation [as 别名]
# 或者: from scipy.spatial.transform.Rotation import from_rotvec [as 别名]
def test_rotvec_calc_pipeline():
    # Include small angles
    rotvec = np.array([
        [0, 0, 0],
        [1, -1, 2],
        [-3e-4, 3.5e-4, 7.5e-5]
        ])
    assert_allclose(Rotation.from_rotvec(rotvec).as_rotvec(), rotvec)
开发者ID:ElDeveloper,项目名称:scipy,代码行数:10,代码来源:test_rotation.py

示例3: test_constant_attitude

# 需要导入模块: from scipy.spatial.transform import Rotation [as 别名]
# 或者: from scipy.spatial.transform.Rotation import from_rotvec [as 别名]
def test_constant_attitude():
    times = np.arange(10)
    rotations = Rotation.from_rotvec(np.ones((10, 3)))
    spline = RotationSpline(times, rotations)

    times_check = np.linspace(-1, 11)
    assert_allclose(spline(times_check).as_rotvec(), 1, rtol=1e-15)
    assert_allclose(spline(times_check, 1), 0, atol=1e-19)
    assert_allclose(spline(times_check, 2), 0, atol=1e-19)

    assert_allclose(spline(5.5).as_rotvec(), 1, rtol=1e-15)
    assert_allclose(spline(5.5, 1), 0, atol=1e-19)
    assert_allclose(spline(5.5, 2), 0, atol=1e-19)
开发者ID:WarrenWeckesser,项目名称:scipy,代码行数:15,代码来源:test_rotation_spline.py

示例4: test_from_generic_rotvec

# 需要导入模块: from scipy.spatial.transform import Rotation [as 别名]
# 或者: from scipy.spatial.transform.Rotation import from_rotvec [as 别名]
def test_from_generic_rotvec():
    rotvec = [
            [1, 2, 2],
            [1, -1, 0.5],
            [0, 0, 0]
            ]
    expected_quat = np.array([
        [0.3324983, 0.6649967, 0.6649967, 0.0707372],
        [0.4544258, -0.4544258, 0.2272129, 0.7316889],
        [0, 0, 0, 1]
        ])
    assert_array_almost_equal(
            Rotation.from_rotvec(rotvec).as_quat(),
            expected_quat)
开发者ID:ElDeveloper,项目名称:scipy,代码行数:16,代码来源:test_rotation.py

示例5: test_from_rotvec_small_angle

# 需要导入模块: from scipy.spatial.transform import Rotation [as 别名]
# 或者: from scipy.spatial.transform.Rotation import from_rotvec [as 别名]
def test_from_rotvec_small_angle():
    rotvec = np.array([
        [5e-4 / np.sqrt(3), -5e-4 / np.sqrt(3), 5e-4 / np.sqrt(3)],
        [0.2, 0.3, 0.4],
        [0, 0, 0]
        ])

    quat = Rotation.from_rotvec(rotvec).as_quat()
    # cos(theta/2) ~~ 1 for small theta
    assert_allclose(quat[0, 3], 1)
    # sin(theta/2) / theta ~~ 0.5 for small theta
    assert_allclose(quat[0, :3], rotvec[0] * 0.5)

    assert_allclose(quat[1, 3], 0.9639685)
    assert_allclose(
            quat[1, :3],
            np.array([
                0.09879603932153465,
                0.14819405898230198,
                0.19759207864306931
                ]))

    assert_equal(quat[2], np.array([0, 0, 0, 1]))
开发者ID:ElDeveloper,项目名称:scipy,代码行数:25,代码来源:test_rotation.py

示例6: test_malformed_2d_from_rotvec

# 需要导入模块: from scipy.spatial.transform import Rotation [as 别名]
# 或者: from scipy.spatial.transform.Rotation import from_rotvec [as 别名]
def test_malformed_2d_from_rotvec():
    with pytest.raises(ValueError, match='Expected `rot_vec` to have shape'):
        Rotation.from_rotvec([
            [1, 2, 3, 4],
            [5, 6, 7, 8]
            ])
开发者ID:ElDeveloper,项目名称:scipy,代码行数:8,代码来源:test_rotation.py

示例7: test_malformed_1d_from_rotvec

# 需要导入模块: from scipy.spatial.transform import Rotation [as 别名]
# 或者: from scipy.spatial.transform.Rotation import from_rotvec [as 别名]
def test_malformed_1d_from_rotvec():
    with pytest.raises(ValueError, match='Expected `rot_vec` to have shape'):
        Rotation.from_rotvec([1, 2])
开发者ID:ElDeveloper,项目名称:scipy,代码行数:5,代码来源:test_rotation.py

示例8: test_from_2d_single_rotvec

# 需要导入模块: from scipy.spatial.transform import Rotation [as 别名]
# 或者: from scipy.spatial.transform.Rotation import from_rotvec [as 别名]
def test_from_2d_single_rotvec():
    rotvec = [[1, 0, 0]]
    expected_quat = np.array([[0.4794255, 0, 0, 0.8775826]])
    result = Rotation.from_rotvec(rotvec)
    assert_array_almost_equal(result.as_quat(), expected_quat)
开发者ID:ElDeveloper,项目名称:scipy,代码行数:7,代码来源:test_rotation.py


注:本文中的scipy.spatial.transform.Rotation.from_rotvec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。