Create a unit sphere by subdividing all triangles of an octahedron recursively.
The unit sphere has a radius of 1, which also means that all points in this sphere (assumed to have centre at [0, 0, 0]) have an absolute value (modulus) of 1. Another feature of the unit sphere is that the unit normals of this sphere are exactly the same as the vertices.
This recursive method will avoid the common problem of the polar singularity, produced by 2d (lon-lat) parameterization methods.
If you require a sphere with another radius than that of 1, simply multiply every single value in the vertex array by this new radius (although this will break the “vertex array equal to unit normal array” property)
Creates a unit sphere and returns the top half
Starting with a symmetric sphere of points, removes half the points so that for any pair of points a, -a only one is kept. Removes half the edges so for any pair of edges [a, b]; [-a, -b] only one is kept. The new edges are constructed in a way so that references to any removed point, r, is replaced by a reference to -r. Removes half the triangles in the same way.
Parameters : | recursion_level : int
|
---|---|
Returns : | vertices : array
edges : array
triangles : array
|
See also
create_half_sphere, divide_all
Creates a unit sphere by subdividing a unit octahedron.
Starts with a unit octahedron and subdivides the faces, projecting the resulting points onto the surface of a unit sphere.
Parameters : | recursion_level : int
|
---|---|
Returns : | vertices : array
edges : array
triangles : array
|
See also
create_half_sphere, divide_all
Subdivides a triangle
Parameters : | vertices : ndarray
edges : ndarray
|
---|---|
Returns : | vertices : array
edges : array
triangles : array
|
Notes
Subdivide each triangle in the old approximation and normalize the new points thus generated to lie on the surface of the unit sphere.
Each input triangle with vertices labelled [0,1,2], as shown below, is represented by a set of edges. The edges are written in such a way so that the second vertex in each edge is the first vertex in the next edge. For example:
[0, 1]
[1, 2]
[2, 0]
Make new points:
b = (0+1)/2
c = (1+2)/2
a = (2+0)/2
Construct new triangles:
t1 [0b,ba,a0]
t2 [1c,cb,b1]
t3 [2a,ac,c2]
t4 [ba,ac,cb]
Like this:
1
/\
/ \
b/____\ c
/\ /\
/ \ / \
/____\/____\
0 a 2
Normalize a, b, c.
When constructed this way edges[triangles,0] or edges[triangles,1] will both return the three vertices that make up each triangle (in a different order):
Code was adjusted from dlampetest website http://sites.google.com/site/dlampetest/python/triangulating-a-sphere-recursively
Normalize a numpy array of 3 component vectors shape=(n,3)
Returns a triangulated half sphere
Removes half the vertices, edges, and triangles from a unit sphere created by create_unit_sphere