The following illustrate methods for generating a facet approximation to a sphere. The most straightforward method uses polar to cartesian coordinates, if theta and phi as shown in the diagram below are varied the resulting vector describes points on the surface of a sphere.
![]()
|
The equations of the points on the surface of the sphere are
y = cos(theta) sin(phi) z = sin(theta)
0 <= phi <= 360 |
To create a facet approximation, theta and phi are stepped in small angles between their respective bounds. So if we take the angle step size to be dtheta and dphi, the four vertices of any facet correspond to
|
The main drawback with this simple approach is the non uniform resolution (facet size) over the surface of the sphere, in particular, the facets become smaller at the poles. |
![]() |
The sphere can be generated at any resolution, the following shows a progression from 45 degrees through to 5 degree angle increments.

The number of facets being (180 / dtheta) (360 / dphi), the 5 degree example on the right contains almost 2600 facets.
Source code
|
Another method derives a faceted representation of a sphere by starting with a crude approximation and repeatedly bisecting the facets at the same time moving them to the surface of the sphere. The simplest starting form could be a tetrahedron, in the first iteration the 4 facets are split into 4 by bisecting the edges. In each iteration this is repeated, that is, each facet is further split into 4 smaller facets. Either during or at the end of this process (it doesn't matter when) each vertex is moved to the boundary of the sphere by simply normalising the vector and scaling by the desired radius. |
![]() |
The following illustrates the sphere after 5 iterations, the number of facets increases on each iteration by 4 so this representation has 1024 facets.

Perhaps unexpectedly, all the facets are not the same size, those nearer the vertices of the original tetrahedron are smaller. The above example resulted in a triangular faceted model, if a cube is used as the starting form then a representation with rectangular facets can be derived.

As in the tetrahedron example the facets are split into 4 and thus the number of facets increases by a factor of 4 on each iteration. The representation on the far right consists of 6144 facets.

The nonuniformity of the facets most disappears if one uses an octahredon as the starting shape. Bisecting the triangular facets results in sphere approximations with 8, 32, 128, 512, 2048, .... facets as the iteration count increases.

Source code
PovRay example courtesy Louis Bellotto
Uniform Distribution
A simple way to randomly (uniform) distribute points on sphere is called the "hypercube rejection method". To apply this to a unit cube at the origin, choose coordinates (x,y,z) each uniformly distributed on the interval [-1,1]. If the length of this vector is greater than 1 then reject it, otherwise normalise it and use it as a sample.
Spherical triangle
The same technique can be used to form and represent a spherical triangle, that is, the triangle formed by three points on the surface of a sphere, bordered by three great circle segments.

The algorithm and the conventions used in the sample source code provided is illustrated below. The three vertices of the triangle are each defined by two angles, longitude and latitude, on each iteration the number of triangles increases by a factor of 4.

Facet Approximation to a CylinderWritten by Paul BourkeSee also: Creating a plane/disk perpendicular to a line segment
The following describes how to represent an "ideal" cylinder (or cone) by discrete facets. The reasons for wanting to do this mostly stem from environments that don't support a cylinder primitive, for example OpenGL, DXF and STL. A very general definition of a cylinder will be used, it will be defined by two end points and a radius at each end. A traditional cylinder will have the two radii the same, a tapered cylinder will have different radii, a cone will have a zero radius at one end. |
![]()
|
The following images show the cylinders with either 4 vertex faces or entirely 3 vertex facets. Note that since the 4 vertex polygons are coplanar, splitting them into two 3 vertex facets doesn't improve the resolution. End caps are normally optional, whether they are needed or not is application dependent.


|
In order to specify the vertices of the facets making up the cylinder one first needs two vectors that are both perpendicular to the cylinder axis as well as perpendicular to each other. These are shown in red and blue in the figure on the right. There are a number of ways of creating these two vectors, they normally require the formation of any vector that is not colinear with the cylinder axis. The cross product of that vector with the cylinder axis (P2-P1) gives one of the vectors (A say), taking the cross product of this new vector with the axis gives the other vector (B). These two perpendicular vectors are then normalised. Given the two perpendicular vectors A and B one can create vertices around each rim of the cylinder. So, for a 4 vertex facet the vertices might be given by the following where theta2 - theta1 is some suitably small angle that determines the roughness of the approximation. |
|
q[0] = P1 + r1 * cos(theta1) * A + r1 * sin(theta1) * B
q[1] = P2 + r2 * cos(theta1) * A + r2 * sin(theta1) * B
q[2] = P2 + r2 * cos(theta2) * A + r2 * sin(theta2) * B
q[3] = P1 + r1 * cos(theta2) * A + r1 * sin(theta2) * B
Note P1,P2,A, and B are all vectors in 3 space. r1 and r2 are the radii at the two ends.
Written as some pseudo C code the facets might be created as follows
create A and B
for (i=0;i<NFACETS;i++) {
n = 0;
theta1 = i * TWOPI / N;
theta2 = (i+1) * TWOPI / N;
q[n].x = P1.x + r1 * cos(theta1) * A.x + r1 * sin(theta1) * B.x
q[n].y = P1.y + r1 * cos(theta1) * A.y + r1 * sin(theta1) * B.y
q[n].z = P1.z + r1 * cos(theta1) * A.z + r1 * sin(theta1) * B.z
n++;
q[n].x = P2.x + r2 * cos(theta1) * A.x + r2 * sin(theta1) * B.x
q[n].y = P2.y + r2 * cos(theta1) * A.y + r2 * sin(theta1) * B.y
q[n].z = P2.z + r2 * cos(theta1) * A.z + r2 * sin(theta1) * B.z
n++;
if (r2 != 0) {
q[n].x = P2.x + r2 * cos(theta2) * A.x + r2 * sin(theta2) * B.x
q[n].y = P2.y + r2 * cos(theta2) * A.y + r2 * sin(theta2) * B.y
q[n].z = P2.z + r2 * cos(theta2) * A.z + r2 * sin(theta2) * B.z
n++;
}
if (r1 != 0) {
q[n].x = P1.x + r1 * cos(theta2) * A.x + r1 * sin(theta2) * B.x
q[n].y = P1.y + r1 * cos(theta2) * A.y + r1 * sin(theta2) * B.y
q[n].z = P1.z + r1 * cos(theta2) * A.z + r1 * sin(theta2) * B.z
n++;
}
do something with q[0..n]
}
Note
The algorithm described here will cope perfectly well with negative radii. If one radius is negative and the other positive then the cylinder will cross through at a single point, effectively looking like two end-to-end cones. This does lead to facets that have a twist in them which is not always allowed.
The end caps are simply formed by first checking the radius at each end, if it is not 0 then additional 3 vertex faces are created with vertices P1, q[0], q[3] and/or P2, q[1], q[2].
If your application requires only 3 vertex facets then the 4 vertex facets above can be split into q[0], q[1], q[2] and q[0], q[2], q[3].
Pay attention to any facet orderings requirements of your application. Many packages expect normals to be pointing outwards, the exact ordering of the vertices also depends on whether you are using a left or right handed coordinate system.
Many computer modelling and visualisation problems lend themselves to placing markers at points in 3 space. It may be that such markers are a natural consequence of the object being studied (for example: chaotic attractors) or it may be that forming other higher level primitives such as tubes or planar facets may be problematic given the description of the object being modelled.
A simple and directionally symmetric marker is the sphere, a point is discounted here, even though it can be considered to be a sphere of zero radius, because most rendering packages do not support such ideal non-real entities. (A ray from a raytracer will never intersect a point which occupies no volume, in the same way, lines can generally not be rendered)
Another reason for wanting to model using spheres as markers is that many rendering packages handle spheres very efficiently. The computationally expensive part of raytracing geometric primitives is testing the intersection of a ray with the primitive. Such a test for a sphere is the most efficient of all primitives, one only needs to determine whether the closest position of the center of the sphere to the ray is less than the radius of the sphere.
The first example will be modelling a curve in space. The figures below show the same curve represented with an increased number of points, a sphere at each point.



Modelling chaotic attractors is a natural candidate for modelling with spheres because the points are not generated sequentially.

Surfaces can also be modelled with spheres although this can obviously be very inefficient. The following is an example from a project to visualise the Steiner surface.

Each strand of the rope is modelled as a series of spheres, each tracing a sinusoidal route through space.


Some biological forms lend themselves naturally to being modelled with spherical building blocks as it adds an existing surface texture. Some sea shells for example have a rippled effect

Representing attractors
|
|
Creating box shapes is very common in computer modelling applications. The boxes used to form walls, table tops, steps, etc generally have perfectly sharp edges. Such sharpness does not normally occur in real life because of wear and for safety reasons.
There are many ways of introducing curvature and ideally this would be done in the rendering phase. One modelling technique is to turn edges into cylinders and the corners into spheres. The planar facets that made up the original object are trimmed back until they are tangent to the sphere and/or cylinder surface.
To illustrate this consider the following which shows the corner of a box converted into a corner with curvature.

Over the whole box, each of the 6 facets reduce in size, each of the 12 edges become cylinders, and each of the 8 vertices become spheres.
One problem with this technique as described here is that the resulting object does not normally have the desired effect internally. If this is important then the cylinders and spheres described above need to be turned into the appropriate cylindrical and spherical wedges/sections. In the following example a cube with sides of length 2 and increasing edge radii is used to illustrate the effect.
radius = 0
Just a cube





Most rendering engines support simple geometric primitives such as planes, spheres, cylinders, cones, etc. Many times a pipe is needed, by pipe I am refering to a tube like structure which passes through 3D space. The actual path is irrelevant but might be an arc or a Bezier/Spline curve defined by control points in space.
The standard method of geometrically representing this structure, as illustrated here, uses combinations of cylinders and spheres. Basically the curve is split into a straight line approximation to the desired level or resolution. Each straight line segment is represented by a cylinder. Since this would lead to gaps at the intersection of cylinders, spheres of the same radius are placed at the intersection points. Optionally disks can be placed at the end points to seal the pipe.

Note 1
If the radius of the pipe is to change along the path then the cylinders need to be replaced with a cone sections, namely a cylinder with different radii at each end. The radius of each cylinder is the same at an intersection point so an appropriate sphere still fills the gaps.

Note 2
This method is only suitable if the pipe is to be viewed from the outside.
As an example, the following pipes are arc paths, 20 straight line sections per pipe.
