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)
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)
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)
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)
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)
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]))
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
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]))