Distributing Points on a Sphere

Written by Paul Bourke
June 1996


The following describes two (inefficient) methods of evenly distributing points on a sphere. They do however allow for an arbitrary number of points to be distributed unlike many other algorithms which only work for a restricted set of points.

The first approach is to randomly distribute the required number of points on a sphere of the desired radius. The iteration involves finding the closest two points and then moving them apart slightly.

The following shows the results for 100 and 400 points, the disks have a radius of the minimum distance.

C source code: source1.c

Physical method

See Particle Systems for more details on modelling with particle systems.

A more "fun" method is to use a physical particle method. For example we can randomly distribute point particles in 3D space and join each particle to a central fixed particle (intended center of the sphere) with springs with the same rest length.

If we place the same electric charge on each particle (except perhaps the particle in the center) then each particle will repel every other particle. This system will tend to a stable configuration where each particle is equidistant from the center (due to spring forces) and each particle maximally separated from its closest neighbours (electric repulsive forces). It is important to model this with viscous damping as well as with spring damping to avoid oscillatory motion. An example using 31 particles randomly distributed in a cube is shown in the animation above. A midpoint ODE solver was used to solve the equations of motion, it took only 200 steps to reach a stable (minimum energy) configuration.

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.

Contribution by Jonathan D. Lettvin

C++ source code: diffuse.cpp

Contribution by Max Downey

Java implementation: java.tar.gz

Contribution by Orion Elenzil

Orion Elenzil proposes that by choosing uniformly distributed polar coordinates theta (0 <= theta < 360) and phi (0 <= phi <= pi/2) but the using the sqrt(phi) results in points uniformly distributed on the surface of a hemisphere. If the poles lie along the z axis then the position on a unit hemisphere sphere is

x = cos(sqrt(phi)) cos(theta)
y = cos(sqrt(phi)) sin(theta)
z = sin(sqrt(phi))

A whole sphere is obtained by simply randomising the sign of z.