Exemple #1
0
def test_rotate_vector_with_units():
    vector = [1, 0, 0] * u.m
    angle = 90 * u.deg
    axis = 'y'
    expected_vector = [0, 0, -1] * u.m
    result = util.rotate(vector, angle, axis)
    assert_quantity_allclose(result, expected_vector, atol=1e-16 * u.m)
Exemple #2
0
def test_rotate_vector_with_units():
    vector = [1, 0, 0] * u.m
    angle = 90 * u.deg
    axis = "y"
    expected_vector = [0, 0, -1] * u.m
    result = util.rotate(vector, angle, axis)
    assert_quantity_allclose(result, expected_vector, atol=1e-16 * u.m)
Exemple #3
0
def test_rotate_unitless_vector():
    vector = [1, 0, 0]
    angle = 90 * u.deg
    axis = 'z'
    expected_vector = [0, 1, 0]
    result = util.rotate(vector, angle, axis)
    assert_allclose(result, expected_vector, atol=1e-16)
Exemple #4
0
def test_rotate_unitless_vector():
    vector = [1, 0, 0]
    angle = 90 * u.deg
    axis = 'z'
    expected_vector = [0, 1, 0]
    result = util.rotate(vector, angle, axis)
    assert_array_almost_equal(result, expected_vector)
Exemple #5
0
def test_rotate_vector_with_units():
    vector = [1, 0, 0] * u.m
    angle = 90 * u.deg
    axis = 'y'
    expected_vector = [0, 0, -1] * u.m
    result = util.rotate(vector, angle, axis)
    assert_array_almost_equal(result.value, expected_vector.value)
Exemple #6
0
 def test_rotation_around_coordinate_axis(self):
     vec = np.array([1, 0, 0])
     ax = 2
     angle = np.pi / 2
     rot_vec = rotate(vec, ax, angle)
     assert_array_almost_equal(rot_vec, np.array([0, 0, -1]))
Exemple #7
0
 def test_vectorize_vec(self):
     vec = np.random.rand(3, 10)
     ax = 1
     angle = np.random.rand()
     rot_vec = rotate(vec, ax, angle)
     assert rot_vec.shape == vec.shape
Exemple #8
0
 def test_rotation_around_arbitrary_axis(self):
     vec = np.array([1, 0, 0])
     ax = np.array([0, 0, 1])
     angle = np.pi / 2
     rot_vec = rotate(vec, ax, angle)
     assert_array_almost_equal(rot_vec, np.array([0, 1, 0]))