- 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!
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!
