Exemple #1
0
def test_from_wcs():
    ucs = PassTroughUCS()
    assert ucs.from_wcs((1, 2, 3)) == Vec3(1, 2, 3)
    assert ucs.from_wcs((3, 4, 5)) == Vec3(3, 4, 5)

    ucs2 = UCS()
    assert ucs.from_wcs((1, 2, 3)) == ucs2.from_wcs(Vec3(1, 2, 3))
    assert ucs.from_wcs((3, 4, 5)) == ucs2.from_wcs(Vec3(3, 4, 5))
Exemple #2
0
def test_translation():
    ucs = UCS(origin=(3, 4, 5))
    assert ucs.origin == (3, 4, 5)
    assert ucs.ux == (1, 0, 0)
    assert ucs.uy == (0, 1, 0)
    assert ucs.uz == (0, 0, 1)
    assert ucs.from_wcs((3, 4, 5)) == (0, 0, 0)
    assert ucs.to_wcs((1, 1, 1)) == (4, 5, 6)
Exemple #3
0
def test_ucs_init():
    ucs = UCS()
    assert ucs.origin == (0, 0, 0)
    assert ucs.ux == (1, 0, 0)
    assert ucs.uy == (0, 1, 0)
    assert ucs.uz == (0, 0, 1)

    assert ucs.from_wcs((3, 4, 5)) == (3, 4, 5)
    assert ucs.to_wcs((5, 4, 3)) == (5, 4, 3)
Exemple #4
0
def test_arbitrary_ucs():
    origin = Vector(3, 3, 3)
    ux = Vector(1, 2, 0)
    def_point_in_xy_plane = Vector(3, 10, 4)
    uz = ux.cross(def_point_in_xy_plane - origin)
    ucs = UCS(origin=origin, ux=ux, uz=uz)
    def_point_in_ucs = ucs.from_wcs(def_point_in_xy_plane)
    assert def_point_in_ucs.z == 0
    assert ucs.to_wcs(def_point_in_ucs) == def_point_in_xy_plane
    assert ucs.is_cartesian is True
Exemple #5
0
def test_arbitrary_ucs():
    origin = Vec3(3, 3, 3)
    ux = Vec3(1, 2, 0)
    def_point_in_xy_plane = Vec3(3, 10, 4)
    uz = ux.cross(def_point_in_xy_plane - origin)
    ucs = UCS(origin=origin, ux=ux, uz=uz)
    m = Matrix44.ucs(ucs.ux, ucs.uy, ucs.uz, ucs.origin)
    def_point_in_ucs = ucs.from_wcs(def_point_in_xy_plane)

    assert ucs.ux == m.ux
    assert ucs.uy == m.uy
    assert ucs.uz == m.uz
    assert ucs.origin == m.origin

    assert def_point_in_ucs == m.ucs_vertex_from_wcs(def_point_in_xy_plane)
    assert def_point_in_ucs.z == 0
    assert ucs.to_wcs(def_point_in_ucs).isclose(def_point_in_xy_plane)
    assert ucs.is_cartesian is True