Algorithm Help

Sassy Rabbit

Member
Sep 7, 2007
89
0
0
Not sure if this can be done.

I am writing a program to place objects evenly spaced on a spherical shell. Catch is, as the radius becomes bigger more objects are placed onto the shell. So in the first shell 6 particles are places at each of the 6 poles. In the second shell 14 particles are places - one at each of the 6 poles and on at all of the combinations of 45(deg angles).

The nested loops would look like this:

//Shell
for(int s = 1; s < Number of shells; s++)
{
//azimuthal angle
for(int a = -s; a <= s; a++)
{
//polar angle
for( HELP NEEDED HERE!)
{
place object on shell based on radius, azimuthal and polar angle
}
}
}

Basically - I want to have a structure that looks like this in the first shell the polar angle loop would operate 1,4 and 1 times for each sequential step through the azimuthal angle.

In the second shell, it would operate 1,4,8,4,1 times.

I'm not sure if this is a silly question to be asking, but I can't figure out a statement to describe the polar angle loop in a way that would make it operate correctly. So, after a few hours of staring at the problem this seemed like a decent place to come for help.

Thanks!
 

JACKDRUID

Senior member
Nov 28, 2007
729
0
0
I really don't get it... what are you trying to do? whats the relationship between shell,azimuthal angle, and polar angle?
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I'm with Jack. Sort of confused as to what exactly you need help with. Let's step back to the beginning. It sounds like you want to evenly distribute shapes across the surface of the sphere, with the number of shapes dependent on how large the diameter of the sphere is. Is that correct?

For any given great circle you can determine the circumference given the radius. Once having the circumference you can figure out how many shapes of size x will fit, and determine the spacing between them. The trick would be what you do as the meridian lines converge near the poles (of which I believe there are two, not six). Since by definition the meridians converge to 0 distance at the poles, no shapes will fit there.

Another approach is to look up an algorithm for decomposing a sphere into primitives, determine how many vertexes you want from the result, and then place a shape at each vertex.