예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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]))
예제 #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
예제 #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]))