Example #1
0
def test_create_vector():
    p1 = [0, 0, 0]
    p2 = [-1, -1, -1]
    v = halfedge_mesh.create_vector(p1, p2)
    assert halfedge_mesh.allclose(v, [-1, -1, -1])

    p3 = [4, 4, 4]
    v = halfedge_mesh.create_vector(p2, p3)
    assert halfedge_mesh.allclose(v, [5, 5, 5])
Example #2
0
def test_normalize_vectors():
    assert halfedge_mesh.allclose(halfedge_mesh.normalize([1, 2, 3]),
                                  [0.26726124, 0.53452248, 0.80178373])

    assert halfedge_mesh.allclose(halfedge_mesh.normalize([3.43, 566.7, 9.6]),
                                  [0.00605161, 0.99983824, 0.01693744])

    assert halfedge_mesh.allclose(
        halfedge_mesh.normalize([100000., 1222222., 30000000]),
        [0.00333055, 0.04070674, 0.99916559])

    assert halfedge_mesh.allclose(halfedge_mesh.normalize([0, 0, 0]),
                                  [0, 0, 0])
Example #3
0
def test_allclose_list_int_float():
    assert halfedge_mesh.allclose(1, 1)
    assert halfedge_mesh.allclose(0, 0)
    assert halfedge_mesh.allclose(-1, -1)
    assert halfedge_mesh.allclose([1.34, 1.4, 5688.66], [1.34, 1.4, 5688.66])
    assert halfedge_mesh.allclose([-1.34, -1.4, -5688.66],
                                  [-1.34, -1.4, -5688.66])
    assert halfedge_mesh.allclose([1.33], [1.33])
    assert halfedge_mesh.allclose(1.33, 1.33)
    assert halfedge_mesh.allclose([1, 2, 3, 4], [1, 2, 3, 4])
    assert halfedge_mesh.allclose([-1, -2, -3, -4], [-1, -2, -3, -4])
Example #4
0
    def test_get_angle_normal(self, cube_off_mesh, cube_negative_off_mesh):

        assert cube_off_mesh.facets[0].halfedge.vertex.index == 1
        assert cube_off_mesh.facets[0].halfedge.prev.vertex.index == 0
        assert halfedge_mesh.allclose(
            cube_off_mesh.facets[0].halfedge.get_angle_normal(), math.pi / 2.0)

        assert cube_off_mesh.facets[1].halfedge.vertex.index == 7
        assert cube_off_mesh.facets[1].halfedge.prev.vertex.index == 4
        assert halfedge_mesh.allclose(
            cube_off_mesh.facets[1].halfedge.get_angle_normal(), math.pi / 2.0)

        assert cube_off_mesh.facets[3].halfedge.next.vertex.index == 2
        assert cube_off_mesh.facets[3].halfedge.next.prev.vertex.index == 5
        assert halfedge_mesh.allclose(
            cube_off_mesh.facets[3].halfedge.next.get_angle_normal(), 0.0)

        assert halfedge_mesh.allclose(
            cube_negative_off_mesh.get_halfedge(5, 7).get_angle_normal(),
            -0.67967381890824385)
Example #5
0
def test_dot():
    assert halfedge_mesh.dot([1, 2, 3], [1, 2, 3]) == 14
    assert halfedge_mesh.dot([-1, -2, -3], [1, 2, 3]) == -14
    assert halfedge_mesh.dot([1, 2, 3], [-1, -2, -3]) == -14
    assert halfedge_mesh.dot([0, 1, 0], [1, 0, 0]) == 0
    assert halfedge_mesh.dot([0, -1, 0], [-1, 0, 0]) == 0
    assert halfedge_mesh.dot([1, 0, 0], [0, 0, 1]) == 0
    assert halfedge_mesh.dot([1], [2]) == 2
    assert halfedge_mesh.dot([3, 4], [10, 8]) == 62
    assert halfedge_mesh.allclose(
        (halfedge_mesh.dot([1.23, 4.5, 0.0], [1.3865, 4.56, 81.3865])),
        22.225394999999999)
Example #6
0
 def test_get_vertex(self, cube_off_mesh):
     mesh_vertex = cube_off_mesh.vertices[0].get_vertex()
     test_vertex = halfedge_mesh.Vertex(1, -1, -1, 0).get_vertex()
     assert halfedge_mesh.allclose(mesh_vertex, test_vertex)