I'm looking for any algorithm that can return a list of Vector3 coordinates that form a sphere. If you read the list from the beginning it would appear the sphere was expanding.

The only algorithms I've found are for circles, the algorithm doesn't have to make a sphere of a particular radius, just a number of coordinates would be fine.

If anyone could point me in the right direction for such an algorithm that would be great. Any language or even just sudo code for a basic algorithm would be appreciated.

  • 2
    \$\begingroup\$ Can you explain in more detail what you're trying to achieve (or possibly point us to one of the algorithms you've found fir circles)? As the question stands now I'm not sure I understand what you're looking for. \$\endgroup\$
    – bornander
    Nov 3, 2015 at 7:24
  • \$\begingroup\$ I'm looking for an algorithm that will generate a sphere built out of cubes. The algorithm should start in the center and add cubes from the inside out to form a sphere. I'm looking for an algorithm that could add those coordinates of the cubes, in order (from the center of the sphere to outside of the sphere) to a List. \$\endgroup\$ Nov 3, 2015 at 7:34
  • \$\begingroup\$ The thing is I don't want the list to add coordinates that would build the sphere from bottom to top or left to right, I need the list to be in order of proximity to the center of the sphere. \$\endgroup\$ Nov 3, 2015 at 7:36
  • \$\begingroup\$ The order the algorithm works in doesn't matter then, I guess, as you can always sort the list it produces by the distance from the center of the sphere? \$\endgroup\$
    – bornander
    Nov 3, 2015 at 7:40
  • \$\begingroup\$ I could do that however couldn't that put limitations on it's efficiency? \$\endgroup\$ Nov 3, 2015 at 7:48

1 Answer 1


If I understood what you're asking , you can start from Spherical coordinate system enter image description here

Very pseudo code to "list" a sphere from top to bottom:

Let r be radius.

Let PI = 3.14...

Let's use degrees.

For theta =0..180 
   For phi =0..360

Where PolarToCartesian:

x=r * sin(toRad(theta)) * cos(toRad(phi))

y=r * sin(toRad(theta)) * sin(toRad(phi))

z=r * cos(toRad(theta))

and toRad converts degrees into radians

  • \$\begingroup\$ Please note though, the vertices will not be uniformly distributed - there will be much higher density of vertices around poles. \$\endgroup\$
    – wondra
    Nov 3, 2015 at 18:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .