Example #1
0
def test_edges():
    _, cells = meshzoo.triangle(2)
    edges_nodes, edges_cells = meshzoo.create_edges(cells)
    assert numpy.all(edges_nodes == [[0, 1], [0, 3], [1, 2], [1, 3], [1, 4],
                                     [2, 4], [3, 4], [3, 5], [4, 5]])
    assert numpy.all(
        edges_cells == [[3, 1, 0], [5, 4, 2], [6, 3, 4], [8, 7, 6]])
Example #2
0
def test_edges():
    _, cells = meshzoo.triangle(2)
    edges_nodes, edges_cells = meshzoo.create_edges(cells)
    assert numpy.all(
        edges_nodes
        == [[0, 1], [0, 3], [1, 2], [1, 3], [1, 4], [2, 4], [3, 4], [3, 5], [4, 5]]
    )
    assert numpy.all(edges_cells == [[3, 1, 0], [5, 4, 2], [6, 3, 4], [8, 7, 6]])
    return
Example #3
0
def _plot_ellipse_data(
    centers,
    offsets,
    xy_to_2d=lambda xy: xy,
    axes_labels=("x", "y"),
    plot_rgb_triangle=False,
    ellipse_scaling=10,
    ellipse_color="k",
    mesh_resolution=None,
):
    import meshzoo

    plot_flat_gamut(
        plot_planckian_locus=False,
        xy_to_2d=xy_to_2d,
        axes_labels=axes_labels,
        plot_rgb_triangle=plot_rgb_triangle,
        fill_horseshoe=mesh_resolution is None,
    )

    if mesh_resolution is not None:
        # dir_path = os.path.dirname(os.path.realpath(__file__))
        # with open(os.path.join(dir_path, 'data/gamut_triangulation.yaml')) as f:
        #     data = yaml.safe_load(f)
        # points = numpy.array(data['points'])
        # cells = numpy.array(data['cells'])

        points, cells = meshzoo.triangle(
            mesh_resolution,
            corners=numpy.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0],
                                 [0.0, 1.0, 0.0]]),
        )
        points = points[:, :2]

        edges, _ = meshzoo.create_edges(cells)
        pts = xy_to_2d(points.T).T
        lines = pts[edges].T
        plt.plot(*lines, color="0.8", zorder=0)

    _plot_ellipses(centers,
                   offsets,
                   xy_to_2d,
                   ellipse_scaling,
                   facecolor=ellipse_color)
    return