I can think of a few reasons why you would want to evenly distribute points on the surface of a sphere. How one would go about it is another thing entirely. When I recently had to create lights on the surface of a sphere for a light rig, I had to Google around for algorithms and I thought I would share some results with you.
Defining Evenly Distributed
Some would argue that for points to be evenly distributed on a sphere the resulting polygonal object defined by the points needs to have faces that are equal as well as an equal number of faces leading into every vertex. These perfect shapes are known as Platonic Solids.
There are unfortunately only five platonic solids: the tetrahedron, cube, octahedron, dodecahedron and icosahedron each having 4, 8, 6, 20 and 12 vertices.
So unless that is exactly the number of points you wish to have around your sphere we must somehow redefine evenly distributed. There is a great discussion on this titled “Topics On Sphere Distributions” by Dave Rusin.
In our case, let’s ignore how the points would combine to create a solid and concentrate on the distance relationship to its neighbors considering the whole set. For any given number of points what we want is for the minimum distance between any two points to be as large as possible. Makes sense? If any two closest points in the whole set are as far apart as possible, all points should be equally distant from their closest neighbor. That is what we will define as evenly distributed.
How to achieve even distribution
One of the most precise ways to organize points on a sphere, given our definition, would be to simulate them repelling themselves with equal force until they settled (see this document by Simon Tatham). It would be exact but wouldn’t necessarily be quick. Then there are three algorithms that approximate the same result all the while requiring less computational power.
The first one is Dave Rusin’s Disco Ball. Although it will wield a very precise pattern the algorithm does not allow to specify an exact number of points which are then distributed.
The second one is the method of Saff and Kuijlaars. This second one packs the points much less tightly than the Disco Ball but manages to do so with any arbitrary number of points.
Finally there is an algorithm based on the greek golden ratio, the Golden Section spiral. This last stab at the problem can generate a set packed more evenly than Saff and Kuijlaars while being able to specify any number of points.
Here is a graphical comparison of the three methods.
My Golden Section Spiral
Here is a Python implementation of the Golden Section spiral:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
import math def pointsOnSphere(N): N = float(N) # in case we got an int which we surely got pts =  inc = math.pi * (3 - math.sqrt(5)) off = 2 / N for k in range(0, N): y = k * off - 1 + (off / 2) r = math.sqrt(1 - y*y) phi = k * inc pts.append([math.cos(phi)*r, y, math.sin(phi)*r]) return pts
By passing any arbitrary number of points to the function, it will return an array of points in space representing the locations of all points on a unit sphere. You can then multiply this unit vector by whatever length you wish to get the position on a sphere of any size.
Paste the above code in the script editor followed by this concrete XSI example and run it to see the results:
1 2 3 4 5 6
for pt in pointsOnSphere(80): n = Application.ActiveSceneRoot.AddNull() n.size = 0.05 t = n.Kinematics.Global.Transform t.SetTranslationFromValues(pt, pt, pt) n.Kinematics.Global.Transform = t
Voilà! I hope this helps you on your way to the perfect spherical distribution. ;)
Yeah… I sometimes have a hard time remembering that our job is to make pretty pictures.