Пример #1
0
    def test_addRandomVertex2D(self):
        T = Triangulation()
        self.assertEqual(T.getVerts(), [])

        T.addRandomVertex2D(15, 5)
        self.assertEqual(len(T.getVerts()), 15)

        for vert in T.getVerts():
            self.assertLessEqual(vert.getX(), 15)
            self.assertLessEqual(vert.getY(), 15)

        return
Пример #2
0
    def test_getBoundingTriangle2D(self):

        T = Triangulation()

        for i in range(15):
            v1 = Vertex(
                Point(np.random.random() * 54,
                      np.random.random() * 100))
            v2 = Vertex(
                Point(np.random.random() * 54,
                      np.random.random() * 100))
            v3 = Vertex(
                Point(np.random.random() * 54,
                      np.random.random() * 100))

            T.addVertex(v1)
            T.addVertex(v2)
            T.addVertex(v3)

        triangle = T.getBoundingTriangle2D()

        for vert in T.getVerts():
            self.assertEqual(
                Triangulation.Orient2D(vert, triangle.getVert1(),
                                       triangle.getVert2()), True)
            self.assertEqual(
                Triangulation.Orient2D(vert, triangle.getVert2(),
                                       triangle.getVert3()), True)
            self.assertEqual(
                Triangulation.Orient2D(vert, triangle.getVert3(),
                                       triangle.getVert1()), True)

        return