Exemplo n.º 1
0
def test_rotate():
    _test_rotate(
        Coord.from_nothing(),
        Coord.from_zx(Point(0, 0, 0), Point(0, 0, 1), Point(0, -1, 0)),
        Point(1, 1, 0), Point(1, -1, 0))

    _test_rotate(
        Coord.from_zx(Point(0, 0, 0), Point(0, 0, 1), Point(0, 1, 0)),
        Coord.from_zx(Point(0, 0, 0), Point(0, 0, 1), Point(0, -1, 0)),
        Point(1, 1, 0), Point(-1, -1, 0))
Exemplo n.º 2
0
def test_from_coords():
    c1 = Coord.from_xy(P0(), PX(), PY())
    c2 = Coord.from_xy(P0(), PY(), PZ())
    trans_to = Transformation.from_coords(c1, c2)
    trans_from = Transformation.from_coords(c2, c1)

    ps = Point(np.random.random((100, 3)))

    np.testing.assert_array_almost_equal(
        ps.data,
        trans_from.translate(trans_to.translate(ps)).data)

    qs = Quaternion.from_euler(ps)
    np.testing.assert_array_almost_equal(
        qs, trans_from.rotate(trans_to.rotate(qs)))
Exemplo n.º 3
0
def test_rotate():
    q = Quaternion.from_euler(Point(0, 0, np.pi / 2))

    c = Coord.from_nothing(10)

    rc = c.rotate(q)
    assert rc.origin == P0()
    np.testing.assert_almost_equal(rc.x_axis.data, PY(1, 10).data)
    np.testing.assert_almost_equal(rc.y_axis.data, PX(-1, 10).data)
    np.testing.assert_almost_equal(rc.z_axis.data, PZ(1, 10).data)
Exemplo n.º 4
0
def test_translate():
    ca = Coord.from_nothing()
    cb = Coord.from_nothing().translate(Point(1, 0, 0))
    transform = Transformation.from_coords(ca, cb)
    assert transform.translate(Point(0, 0, 0)) == Point(1, 0, 0)
Exemplo n.º 5
0
def test_axes():
    coord = Coord(np.ones((20, 12)))
    assert coord.origin == Point(np.ones((20, 3)))
Exemplo n.º 6
0
def test_rotation_matrix():
    np.testing.assert_array_equal(
        Coord.from_nothing(10).rotation_matrix(),
        np.tile(np.identity(3).reshape(1, 3, 3), (10, 1, 1)))
Exemplo n.º 7
0
def test_from_axes():
    coord = Coord.from_axes(P0(2), PX(1, 2), PY(1, 2), PZ(1, 2))
    assert coord.data[:, :3] == P0(2)
Exemplo n.º 8
0
 def __init__(self, id=None, coords=(None, None, None)):
     Mapobject.__init__(self, id)
     Coord.__init__(self, coords)