Gravitational attraction in discrete time problem...
Heya...
I''ve been working on a nice little particle engine, & for the past couple of days have been trying to do gravity wells (ie a point that accelerates all the other particles toward it).
I don''t know if this is a bad or good way of doing things, but each particle has a location, velocity, & acceleration.
Every frame, the location & velocity are updated:
location += velocity;
velocity += acceleration;
& the acceleration changes are calculated by the gravity well stuff - the change in acceleration is
Gravity Well Mass / ( distance squared )
distance is obviously the distance between the particle & the gravity well.
And here''s the problem - when the particle gets really close to the gravity well, it receives a sudden kick in acceleration, & goes straight past it. Its acceleration immediately starts decreasing, but not fast enough to reverse its direction back towards the gravity well.
Occasionally the variables come out just right so that the particle passes the well once, reverses, passes it again, then by that time has got enough of a speed boost to reach escape velocity.
Its not a divide by zero problem - I get a similar effect even if I cap the acceleration change (eg by testing for when ''distance'' is less than one).
Any suggestions, anyone?
Cheers
Catfish
The reason for this is that a particle will, in one tick, be extremely close to the gravity well, giving it the massive boost. In the next tick, it will already be a fair distance away. It missed out on all the close-range gravitational force pulling it back towards the well. And it''s not easy to solve the problem - I think it requires a pencil, some paper, and some calculus.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement