Dispersing n points uniformly on a sphere
Asked Answered
N

4

18

I am trying to disperse n points on a sphere such that each point has the "same" area "around" it. Basically, I'm trying to integrate a function over a sphere by evaluating at n points and assuming that each area element is the same (and equal to 4pi r^2/n).

My question is very related to this one, but I can't seem to agree that the code presented in the "accepted" answer works as desired (see attached photo, generated by choosing R = 1000, nx = ny = 40). Clearly, my points are much more concentrated at the poles and very un-concentrated along the equator.

Any suggestions?

EDIT: For reference, I did find some software that generates a mesh such that each point has equal "area" around it (scroll down to see uniform area distribution on a sphere), but rather than implement their code I went with a less-time consuming approach: I simply iterated over the azimuthal and polar angles ([0,2pi] and [0,pi]) and computed the ''infinitesimal'' area of each patch (da = r^2 sin theta dtheta dphi). This is basically all I need for integration over the sphere, I was just hoping that uniform-area distribution wouldn't be so hard to implement.

Nesto answered 11/2, 2013 at 3:44 Comment(4)
Check this out !! eqsp.sourceforge.netQuasimodo
The solution in the accepted answer in that question is not very good. Since this is for an integration, picking points that are uniformly distributed over the sphere should be good enough. You don't gain much by minimizing the distance between the points.Unconditioned
@Nesto this is mine solution https://mcmap.net/q/122476/-make-a-sphere-with-equidistant-vertices/2521214 I think that is a bit better (but also not exactly precise +/- int roundig errors between slices) and here https://mcmap.net/q/122475/-location-of-highest-density-on-a-sphere is even better code for you (with inverse transformations)Thralldom
Possible duplicate of Evenly distributing n points on a sphereCammi
L
11

Background information:

There are 4 pi steradians in a sphere, that's the total 'degrees' in a sphere, but I use the term only in the relative sense because steradians are very different from regular radians in a circle, for one, they are 3 dimensional and therefore are solid. Just consider them as ice cream shaped angles in a sphere. enter image description here

http://en.wikipedia.org/wiki/Steradian provides a great example of them.

They have a direct relationship to the radius, like radians in a circle. 1 steradian = 1 unit of radius squared.

So, first find out how many items need to be plotted on the sphere. Let that number be n. sr = steradians (unit of measure) = r^2 (radius squared)

4 pi / n sr = x

x is how many steradians are allocated to each point.

let's say for 4 points.

4 pi / 4 sr = x

pi sr = x So each point will get an allocated space of pi sr.

Now consider this... since you are plotting points, we will consider that each point will be placed in the middle of the allocated space... that is to say, in the middle of the conal shaped area which is what sr is. Now you need to consider something for a moment, is it possible to fill an area completely with circles? Seriously, think about this... it's not is it? Solid circles will always leave room in between in certain spots. Think about a soccer ball for a moment. It is constructed from shapes that can come together to provide even distribution. The point of this thought is to get you to realize that all dots cannot be exactly a certain distance apart--like how a circle has a radius. Yet, the center of the soccer ball squares comes very close and is uniform.

What I would do if I were you, would be to try and write an algorithm to identify the most efficient 'shape' to put each of these 'chunks' of allocated spherical space in... like the soccer ball. Otherwise, I think this might be the best answer you're going to get... 4 pi / n sr = x... , there's no way for each point to be plotted so it exactly the same distance from each other, (except in certain configurations, i.e. it would be possible with special number of points), there may an algorithm out there to find all the special cases.

I am editing this answer to elaborate on the special cases, a little extra information would be good here I think. The special cases for the points to be equidistance apart are that they may form the vertices of platonic solids. There are only 5 basic platonic solid shapes, all others are made by these.

Read this page for more information and proof of this https://www.uwgb.edu/dutchs/symmetry/platonic.htm

Now I can't take credit, I did some quick research and found a similar post https://math.stackexchange.com/questions/279544/return-an-array-of-evenly-distributed-points-on-a-sphere-give-radius-and-origin

Using Euler's polyhedron formula http://plus.maths.org/content/eulers-polyhedron-formula

and the fact that only three basic shapes exist on polyhedrons, 'triangles, squares, and hexagons' you can create an algorithm to round the number of points you want to plot, to the nearest polyhedron shape and plot each one evenly.

enter image description here

Oh, and take a look at this great article, it explains steradians and 3-dimensional 'degrees' much better than I. Link

Lift answered 11/2, 2013 at 7:33 Comment(0)
Q
5

Here's an example algorithm I just whipped up in python:

from numpy import random, cos, sin, sqrt, pi
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

def rand_sphere(n):
  """n points distributed evenly on the surface of a unit sphere""" 
  z = 2 * random.rand(n) - 1   # uniform in -1, 1
  t = 2 * pi * random.rand(n)   # uniform in 0, 2*pi
  x = sqrt(1 - z**2) * cos(t)
  y = sqrt(1 - z**2) * sin(t)
  return x, y, z

x, y, z = rand_sphere(200)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x, y, z)
plt.show()

enter image description here

Again with 10000 points:

enter image description here

Quasimodo answered 11/2, 2013 at 4:4 Comment(6)
Right - this uses a random distribution of points. I was hoping for a structured distribution algorithm. This (mostly) works for this purpose, statistically speaking, but is there a way to guarantee a uniform-area distribution?Nesto
Oh, I think I misunderstood your question. You want them distributed evenly as in a tiling, for example something like a point in the centre of each patch on a soccerball? Intuition tells me this will be impossible except for a few specific values of n.Quasimodo
Yeah, I was hoping that something like that was possible. The tiles don't all have to be the same shape, just (mostly) the same area. But then, randomization does a fairly decent job with that if n is high enough... Maybe your solution is the best after all.Nesto
That's actually a very interesting question, I might go ask it on maths stack exchange!Quasimodo
A really "meaty" maths question indeed, see here. And here are some optimal spherical coverings for n <= 130Quasimodo
Note the second link in @wim's comment (optimal spherical coverings) has moved here.Poltroon
E
2

Could be wrong, but if

  1. setup interactions between two points as I(a,b) = (a-b) / (|a-b|)^3, a,b are threatened as vectors in 3D space
  2. for the first iterations place points as usual (at equal angle distances, how it has been mentioned in the wim post)
  3. at each step of algorithm you will move each point against gradient of summ of I (from 1.) where I is calculated only on direct neighbours
  4. repeat 3 until gradient at each point will become 0.

the algorithm will converge to the configuration what you need. It is time consumpting, but you could cache results for various number of points.

Erosion answered 11/2, 2013 at 8:35 Comment(0)
G
2

There is a software that define a uniform pixelization of the sphere in such a way that each point is surrounded by the same amount of solid angle. Checkout: http://healpix.jpl.nasa.gov/ They also provies several routines to make some useful computations in fortan, C, C++, python, mathlab, among others...

Grew answered 28/7, 2017 at 16:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.