Esempio n. 1
0
def test_rotation_matrix():
    npt.assert_array_almost_equal(rotmat(rad(30), x), [[[1., 0., 0.],
                                                        [0., 0.8660254, -0.5],
                                                        [0., 0.5, 0.8660254]]])
    npt.assert_array_almost_equal(rotmat(rad(30), y), [[[0.8660254, 0., 0.5],
                                                        [0., 1., 0],
                                                        [-0.5, 0, 0.8660254]]])
    npt.assert_array_almost_equal(rotmat(rad(30), z), [[[0.8660254, -0.5, 0.],
                                                        [0.5, 0.8660254, 0],
                                                        [0., 0, 1]]])
Esempio n. 2
0
def test_rotation_matrixes():
    npt.assert_array_almost_equal(rotmat([rad(30), rad(60)], 0), [[[1., 0., 0.],
                                                                   [0., 0.8660254, -0.5],
                                                                   [0., 0.5, 0.8660254]],
                                                                  [[1., 0., 0.],
                                                                   [0., 0.5, -0.8660254, ],
                                                                   [0., +0.8660254, 0.5]]])
Esempio n. 3
0
def test_rotate():
    x, y, z = 0, 1, 2
    v = np.array([1, 2, 3])

    npt.assert_array_almost_equal(rotate(rotmat(np.pi / 2, x), v), [1, -3, 2])
    npt.assert_array_almost_equal(rotate(rotmat(np.pi, x), v), [1, -2, -3])

    npt.assert_array_almost_equal(rotate(rotmat(np.pi / 2, y), v), [3, 2, -1])
    npt.assert_array_almost_equal(rotate(rotmat(np.pi, y), v), [-1, 2, -3])

    npt.assert_array_almost_equal(rotate(rotmat(np.pi / 2, z), v), [-2, 1, 3])
    npt.assert_array_almost_equal(rotate(rotmat(np.pi, z), v), [-1, -2, 3])

    v = np.array([[1, 2, 3], [1, 2, 4]])

    npt.assert_array_almost_equal(rotate(rotmat([np.pi / 2, -np.pi], x), v)[0], [1, -3, 2])
    npt.assert_array_almost_equal(rotate(rotmat([np.pi / 2, -np.pi], x), v)[1], [1, -2, -4])

    npt.assert_array_almost_equal(rotate(rotmat([np.pi / 2, np.pi], y), v)[0], [3, 2, -1])
    npt.assert_array_almost_equal(rotate(rotmat([np.pi / 2, np.pi], y), v)[1], [-1, 2, -4])

    npt.assert_array_almost_equal(rotate(rotmat([np.pi / 2, np.pi], z), v)[0], [-2, 1, 3])
    npt.assert_array_almost_equal(rotate(rotmat([np.pi / 2, np.pi], z), v)[1], [-1, -2, 4])