Exemple #1
0
def sphere(ndiv=6):
    """Create a triangulated spherical surface.

    A high quality approximation of a spherical surface is constructed as
    follows. First an icosahedron is constructed. Its triangular facets are
    subdivided by dividing all edges in `ndiv` parts. The resulting mesh is
    then projected on a sphere with unit radius. The higher `ndiv` is taken,
    the better the approximation. `ndiv=1` results in an icosahedron.

    Returns: 

      A TriSurface, representing a triangulated approximation of a
      spherical surface with radius 1 and center at the origin.
    """
    from elements import Icosa
    from plugins.trisurface import TriSurface

    M = TriSurface(Icosa.vertices,Icosa.faces)
    M = M.subdivide(ndiv).fuse()
    M = M.projectOnSphere()
    return M