|
|
"Crunchy Frog" <dkl### [at] hotmailcom> wrote in message
news:web.4431d5d2aab249115b50195f0@news.povray.org...
> I'm attempting to make an animation that models the 3-body problem, with
> not
> much success. I no matter what I set the starting parameters to, nothing
> ever goes into orbit, which leads me to believe that my physics are
> screwed
> up.
>
> The source is:
>... snip ...
> #declare distSB = (px1-px2)*(px1-px2) + (py1-py2)*(py1-py2) +
> (pz1-pz2)*(pz1-pz2);
> #declare distSC = (px1-px3)*(px1-px3) + (py1-py3)*(py1-py3) +
> (pz1-pz3)*(pz1-pz3);
>
> #declare ax = -((massA*massB)/distSB)*sgn(px1-px2) -
> ((massA*massC)/distSC)*sgn(px1-px3);
> #declare ay = -((massA*massB)/distSB)*sgn(py1-py2) -
> ((massA*massC)/distSC)*sgn(py1-py3);
> #declare az = -((massA*massB)/distSB)*sgn(pz1-pz2) -
> ((massA*massC)/distSC)*sgn(pz1-pz3);
>
> ... snip ...
>
> PS: Does anybody know how to do formatting in this message board thing?
>
Hi Crunchy,
I see that, for each object, you are calculating the square of the distance
to the other two objects.
I think it's shortly after this you start to go horribly wrong :-)
I'm not sure what the intention of the next bit of your SDL is, but I think
you may be thinking that you're calculating the delta in the path that the
object would follow - but I don't think you are. I see that you have the
product of two masses over the distance squared, which gives you the
strength of an accelerative force in a line towards the second object, but
you seem to be adding (or sometimes subtracting) the whole of that into
'ax'. You do the same with the force for the third object. I don't think
this is something you want to do because only a component of the force acts
in the 'x' direction. At the moment, the instant the direction of object 2
relative to object 1 passes across the plane x=0 you switch from adding the
whole of the force in one direction to adding the whole of the force in the
opposite direction.
I assume from the variable names that the variables you are storing are
meant to be the position and velocity of each object. I also assume you're
assuming units that enable you to have an arbitrary gravitational constant
and that distance and time are in arbitrary unitary slices (because you're
ignoring them in your calculations).
I think that to calculate the accelerative force acting on an object you
could take a unit length vector in the direction of the second object and
scale it to represent the force in that direction, then add it to a scaled
vector in the direction of the third object, to give you a total vector in
the direction of the total force whose length represents the force in that
direction.
You should then be able to use that vector to make some of the unpleasant
assumptions about gravity, time and distance units that would enable you to
add components of the vector to the position and velocity vectors. Whether
this gives you objects that orbit around each other will depend on how all
those arbitrary assumptions about units pan out. I'd recommend doing the
calculations on paper to work out positions and velocities that will give
you viable orbits. I think the likelihood of hitting good combinations just
by trial and error is probably quite low. These things don't just happen by
chance you know (or did it?).
As for formatting of postings, I think it's just plain text.
Regards,
Chris B.
Post a reply to this message
|
|