POV-Ray : Newsgroups : povray.binaries.animations : Re: Marbles : Re: Marbles Server Time
19 Jul 2024 02:13:34 EDT (-0400)
  Re: Marbles  
From: Chris Johnson
Date: 30 Sep 2003 20:16:21
Message: <3f7a1cd5$1@news.povray.org>
For simply shaped objects, doing 'perfect' collision detection without multiple time
steps isn't too
difficult.

If you know the velocity and position of two spheres, the exact time that they will
collide (if they
do) is given by a solution to a quadratic equation. Once you have the exact time, you
know the exact
position the spheres are in when they just touch. Its then quite easy to calculate the
force impulse
between them, and their resulting motion.

A general algorithm for doing this would compare each sphere with each other sphere,
and solve the
collision quadratic for each pair of spheres. Some will collide at some point in the
future, some
won't (e.g. if they are going away from each other). If you make a list of all these
possible future
colisions and find the one that is soonest, you can advance the time to that point
(i.e. move all
the spheres by the difference in time between now and the soonest collision) and
calculate the
collision for the two spheres involved in the soonest collision, updating the two
velocities of
those spheres appropriately. Then just run the algorithm again to find the next
collision - find
which is the soonest collision, with the situation of the spheres altered as it is.

This is fairly easy in 2D - the maths to find at exactly what time the spheres
intersect is a bit
tricker in 3D, but its the same concept. Where this gets very difficult (or at least
very fiddly) is
where the objects are not simple shapes.

-Chris


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.