Members - Reputation: 122
Posted 29 June 2001 - 06:13 PM
Staff Emeritus - Reputation: 2069
Posted 29 June 2001 - 10:06 PM
If your application is object-oriented, you could even have the individual balls query the cube elements - the one they are in as well as the adjacent cubes - for the coordinates of any occupying balls, and then do collision detection against them.
You call also simplify your detection by checking the distance between the centers of your spheres rather than for overlap of their volumes. If the vector distance between two balls (centers) is less than twice the radius, there''s been a collision.
I hope this helps somewhat.
Members - Reputation: 1098
Posted 30 June 2001 - 06:57 AM
Then, advance the simulation to the time of the next collision (i.e. the first thing on your list). After the collision, recalculate the new collision time for every other ball, update your list accordingly.
With this method you only have to do n comparisons every collision instead of n^2 comparisons every frame. You also get around the problem of fast balls missing collisions because your simulation time was to high and the ball "warped through" the one it was supposed to collide with.
Members - Reputation: 347
Posted 01 July 2001 - 10:04 PM
To do this project all the balls onto each axis in turn. E.g. on the x axis this means taking the x coordinate of each ball, adding and subtracting it''s radius and noting the values obtained. Do this for every ball and sort the results. Repeat on the y ans z axes.
As the balls move keep track of these values and keep them sorted. Assuming they are not moving far each frame the sorting may not often change or at most it will require a few exchanges, done by a couple of passes of a bubble sort.
A collision can only occur between two balls when they overlap on all three axes. This greatly reduces the number of pairs that need to be considered, and it''s easy to detect new candidate pairs during sorting, e.g. when the upper bound of one object is swapped with the lower bound of another during sorting.
In general the calculations are quick and scale with the number of particles, e.g. O(n). You do not need to know anything about how the objects move (needed for the time prediction technique) or how they are distributed (needed to fix a grid size). And this works well for other shapes: just use bounding spheres or axiz-aligned bounding boxes for more general objects.
Members - Reputation: 132
Posted 05 July 2001 - 08:53 PM
Firstly, check only the x-axis for all the balls, and save all overlapping balls found (radius distance checking). Next, move on to the y-axis, and check only the collisions for those balls having collided in the x-axis. Save only the ones that have 'collided' in both x-axis _and_ y-axis. Finally, check the z-axis collision for those balls that still are left. :D
Is this efficiant - or what?.
Edited by - parklife on July 6, 2001 4:01:45 AM