def test_basic_3d_rotation(): a = np.sqrt(3.0) / 2.0 b = 0.5 # this is a rotation of -30 degrees about the x axis rotation_matrix = np.array([[1, 0, 0], [0, a, b], [0, -b, a]]) rotation = Rotation(rotation_matrix) starting_vector = np.array([0, 1, 0]) transformed = rotation.apply(starting_vector) assert_allclose(np.array([0, a, -b]), transformed)
def test_align_2d_rotation(): rotation_matrix = np.array([[0, 1], [-1, 0]]) rotation = Rotation(rotation_matrix) source = PointCloud(np.array([[0, 1], [1, 1], [-1, -5], [3, -5]])) target = rotation.apply(source) # estimate the transform from source and target estimate = AlignmentRotation(source, target) # check the estimates is correct assert_allclose(rotation.h_matrix, estimate.h_matrix, atol=1e-14)
def test_align_2d_rotation_set_h_matrix_raises_notimplemented_error(): rotation_matrix = np.array([[0, 1], [-1, 0]]) rotation = Rotation(rotation_matrix) source = PointCloud(np.array([[0, 1], [1, 1], [-1, -5], [3, -5]])) target = rotation.apply(source) # estimate the transform from source and source estimate = AlignmentRotation(source, source) # and set the target estimate.set_h_matrix(rotation.h_matrix)
def test_basic_3d_rotation(): a = np.sqrt(3.0)/2.0 b = 0.5 # this is a rotation of -30 degrees about the x axis rotation_matrix = np.array([[1, 0, 0], [0, a, b], [0, -b, a]]) rotation = Rotation(rotation_matrix) starting_vector = np.array([0, 1, 0]) transformed = rotation.apply(starting_vector) assert_allclose(np.array([0, a, -b]), transformed)
def test_basic_2d_rotation(): rotation_matrix = np.array([[0, 1], [-1, 0]]) rotation = Rotation(rotation_matrix) assert_allclose(np.array([0, -1]), rotation.apply(np.array([1, 0])))