Return an array of evenly distributed points on a sphere give Radius and Origin.

4.5k Views Asked by At

Given a sphere of radius $r$, and origin $x,y,z$ what is the simplest way I can generate an evenly distributed array of points on the sphere $(x_1,y_1,z_1),(x_2,y_2,z_2),\cdots(x_n,y_n,z_n)$.

Note I will be writing this as a function in Javascript, if it is any help.

EDIT

Essentially, I want to create a perfectly symmetrical shape with $X$ number of vertices that fits perfectly inside a sphere with radius $R$.

2

There are 2 best solutions below

0
On BEST ANSWER

Use a uniform random number generator to generate an angle $\theta\in[0,2\pi)$ (essentially a longitude) and a $z\in[-1,1]$; the surface area cut by the planes $z=a$ and $z=b$ depends only on $|a-b|$, provided that $a,b\in[-1,1]$, so you get a uniform distribution.

Once you have $\theta$ and $z$, the point is $\left\langle\sqrt{1-z^2}\cos\theta,\sqrt{1-z^2}\sin\theta,z\right\rangle$ in rectangular coordinates.

0
On

At the end of the Mathworld article it says you can generate three Gaussian random variables $x,y,z$. Then $r=\sqrt {x^2+y^2+z^2}$ and $\frac xr, \frac yr, \frac zr$ are equally distributed on the unit sphere.