"Stephan Aspridis" <> wrote in message
news:bt79ub$a0o$04$...
> Hi folks,
>
> a happy new year. I have a little problem with a program I am writing at
> the moment. A loop doesn't behave the way I'd like to (namely, the
> "break" is ignored). This is the code in question:
>
> ----------------------------------
> star[s].planet[0].orbit_distance = pow(SOLDENSITY/EARTHDENSITY,1.0/3.0)
> *sqrt(star[s].mass)*get_random(50.0,150.0)/100.0;
>
> for (p=0;p<orbcount-1;p++){
> x = p+1;
> star[s].planet[x].orbit_distance = star[s].planet[p].orbit_distance
> *get_random(1250.0,2500.0)/1000.0;
> if (star[s].planet[p].orbit_distance > star[s].orbit_limit)
> break;
> }//end for
So, the next planet's orbit distance is between 1.5 and 2.5 times the
current distance, right? And you want to break the loop based on the limit,
but only after calculating the next orbit distance, right?
> planets of 1 present at:
> 0.549 AU
> 1.208 AU
> 2.257 AU
> 5.395 AU <----- ...that is ignored
> 11.480 AU
....
Unless I am missing something blatantly obvious, you should be calculating
orbits up to this point. In addition to what Joona said, I can come up with
two possible explanations: 1) you initialize star[s].orbit_limit too late or
2) you have some kind of an order-of-magnitude problem (initializing orbit
limit to 4000 rather than 4, for example)
Peter