How to use the meshzoo.icosa_sphere function in meshzoo

To help you get started, we’ve selected a few meshzoo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / meshzoo / test / test_sphere.py View on Github external
def test_icosa_sphere(n=16):
    points, cells = meshzoo.icosa_sphere(n)
    # import meshio
    # meshio.write_points_cells("out.vtk", points, {"triangle": cells})
    assert len(points) == 2562
    assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 0.0])
    assert len(cells) == 5120
github nschloe / orthopy / orthopy / sphere / tools.py View on Github external
def write(filename, f):
    """Write a function `f` defined in terms of spherical coordinates to a file.
    """
    import meshio
    import meshzoo
    import cplot

    points, cells = meshzoo.icosa_sphere(5)
    # get spherical coordinates from points
    polar = numpy.arccos(points[:, 2])
    azimuthal = numpy.arctan2(points[:, 1], points[:, 0])
    vals = cplot.get_srgb1(f(polar, azimuthal), colorspace="cam16")

    vals *= 2.5
    vals[vals > 1] = 1
    vals[vals < 0] = 0

    meshio.write_points_cells(
        filename, points, {"triangle": cells}, point_data={"srgb1": vals}
    )
    return