Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
0
def test_align_2d_rotation_set_rotation_matrix():
    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_rotation_matrix(rotation.rotation_matrix)
    # check the estimates is correct
    assert_allclose(target.points, estimate.target.points, atol=1e-14)
Beispiel #4
0
def test_align_2d_rotation_set_rotation_matrix():
    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_rotation_matrix(rotation.rotation_matrix)
    # check the estimates is correct
    assert_allclose(target.points, estimate.target.points, atol=1e-14)
Beispiel #5
0
def test_align_2d_rotation_allow_mirror():
    s_init = PointCloud(np.array([[-1.0, 1.0], [1.0, 1.0], [1.0, -1.0], [-1.0, -1.0]]))
    s_trg = PointCloud(np.array([[1.0, -1.0], [1.0, 1.0], [-1.0, 1.0], [-1.0, -1.0]]))
    # estimate the transform from source and target with mirroring allowed
    tr = AlignmentRotation(s_init, s_trg, allow_mirror=True)
    s_final = tr.apply(s_init)
    assert_allclose(s_final.points, s_trg.points, atol=1e-14)
    # estimate the transform from source and target with mirroring allowed
    tr = AlignmentRotation(s_init, s_trg, allow_mirror=False)
    s_final = tr.apply(s_init)
    assert_allclose(s_final.points, np.array([[-1.0, -1.0], [-1.0, 1.0], [1.0, 1.0], [1.0, -1.0]]), atol=1e-14)
Beispiel #6
0
def test_homog_compose_after_alignment_rotation():
    homog = Homogeneous(np.array([[0, 1, 0],
                                  [1, 0, 0],
                                  [0, 0, 1]]))
    source = PointCloud(np.array([[0, 1],
                                  [1, 1],
                                  [-1, -5],
                                  [3, -5]]))
    r = AlignmentRotation(source, source)
    res = homog.compose_after(r)
    assert(type(res) == Homogeneous)
Beispiel #7
0
def test_align_2d_rotation_allow_mirror():
    s_init = PointCloud(np.array([[-1., 1.], [1., 1.], [1., -1.], [-1., -1.]]))
    s_trg = PointCloud(np.array([[1., -1.], [1., 1.], [-1., 1.], [-1., -1.]]))
    # estimate the transform from source and target with mirroring allowed
    tr = AlignmentRotation(s_init, s_trg, allow_mirror=True)
    s_final = tr.apply(s_init)
    assert_allclose(s_final.points, s_trg.points, atol=1e-14)
    # estimate the transform from source and target with mirroring allowed
    tr = AlignmentRotation(s_init, s_trg, allow_mirror=False)
    s_final = tr.apply(s_init)
    assert_allclose(s_final.points, np.array([[-1., -1.], [-1., 1.], [1., 1.],
                                              [1., -1.]]), atol=1e-14)
def rotation_alignment_angle_ccw(pts1, pts2):
    t = AlignmentRotation(
        Translation(-pts1.centre()).apply(pts1),
        Translation(-pts2.centre()).apply(pts2))

    return 360 - math.degrees(t.axis_and_angle_of_rotation()[-1])