Пример #1
0
    def test_it(self):
        import bezier

        nodes1 = np.asfortranarray([[0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
        triangle1 = bezier.Triangle(nodes1, degree=1, copy=False)
        nodes2 = np.asfortranarray([[0.25, -0.75, 0.25], [0.25, 0.25, -0.75]])
        triangle2 = bezier.Triangle(nodes2, degree=1, copy=False)
        edge_nodes = tuple(edge._nodes for edge in triangle1.edges) + tuple(
            edge._nodes for edge in triangle2.edges)
        edge_info = (
            (0, 0.0, 0.25),
            (5, 0.75, 1.0),
            (3, 0.0, 0.25),
            (2, 0.75, 1.0),
        )
        result = self._call_function_under_test(edge_info, edge_nodes)
        self.assertIsInstance(result, bezier.CurvedPolygon)
        self.assertEqual(result._metadata, edge_info)
        self.assertEqual(result.num_sides, 4)
        # pylint: disable=unbalanced-tuple-unpacking
        edge0, edge1, edge2, edge3 = result._edges
        # pylint: enable=unbalanced-tuple-unpacking
        # First edge.
        expected = np.asfortranarray([[0.0, 0.25], [0.0, 0.0]])
        self.assertEqual(edge0._nodes, expected)
        # Second edge.
        expected = np.asfortranarray([[0.25, 0.25], [0.0, 0.25]])
        self.assertEqual(edge1._nodes, expected)
        # Third edge.
        expected = np.asfortranarray([[0.25, 0.0], [0.25, 0.25]])
        self.assertEqual(edge2._nodes, expected)
        # Fourth edge.
        expected = np.asfortranarray([[0.0, 0.0], [0.25, 0.0]])
        self.assertEqual(edge3._nodes, expected)
Пример #2
0
def unit_triangle():
    """Image for :class:`.triangle.Triangle` docstring."""
    if NO_IMAGES:
        return

    nodes = np.asfortranarray([[0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
    triangle = bezier.Triangle(nodes, degree=1)
    ax = triangle.plot(256, color=BLUE)
    ax.axis("scaled")
    _plot_helpers.add_plot_boundary(ax)
    save_image(ax.figure, "unit_triangle.png")