sphere_tri.m



topics - functions - index - search


sphere_tri.m


The function uses recursive subdivision. The first
approximation is an platonic solid, either an icosahedron,
octahedron or a tetrahedron. Each level of refinement
subdivides each triangle face by a factor of 4 (see also
mesh_refine). At each refinement, the vertices are
projected to the sphere surface (see sphere_project).

A recursion level of 3 or 4 is a good sphere surface, if
gouraud shading is used for rendering.

Usage: FV = sphere_tri(shape,Nrecurse,r)

shape is a string, either of the following:
'ico' starts with icosahedron (most even, default)
'oct' starts with octahedron
'tetra' starts with tetrahedron (least even)

Nrecurse is int >= 1, setting the recursions (default 1)

r is the radius of the sphere (default 1)

FV has fields FV.vertices and FV.faces. The vertices
should be triangulated in clockwise order, as viewed
from the outside in a RHS coordinate system.

The returned struct can be used in the patch command, eg:

% create and plot, vertices: [2562x3] and faces: [5120x3]
FV = sphere_tri('ico',4,1);"
lighting phong; shading interp; figure;"
patch('vertices',FV.vertices,'faces',FV.faces,...
'facecolor',[1 0 0],'edgecolor',[.2 .2 .6]);"
axis off; camlight infinite; camproj('perspective');"

See also: mesh_refine, sphere_project