 Allegro.cc Forums » Programming Questions » Elastic collisions between round objects

 This thread is locked; no one can reply to it.  1   2
 Elastic collisions between round objects
 vpenquerch Member #233 April 2000 > It seems [1-4] means there's 4 URLs where you replace [1-4] with a number 1 to 4 inclusive.Heh, yes, thought that was obvious, sorry Been doing regexp searches too often, I guess...
 orz Member #565 August 2000 Ulf Magnusson: Momentum is still conserved. X momentum was 0 beforehand, is still 0 afterwards. Same for Y momentum. Why 0, you ask? Because the one on the left was +1, the one on the right was -1, the sum was 0. Vincent: Sorry, yes, it would have been obvious if I bothered to read the URL. I didn't read it, I just copied and pasted it into my browsers navigation bar. Evert: If masses are equal then velocity is conserved. Speed is not. Velocity is a vector, speed is the magnitude of velocity. Note that the numbers for the earlier collision example:vX1 = -1.58721vY1 = 0.735375vX2 = -0.0129988vY2 = 0.199577vX1 + vX2 = 1.60vY1 + vY2 = 0.934speed1 + speed2 = 1.94929vX1' = -1.09078vY1' = -0.311503vX2' = -0.509424vY2' = 1.24646vX1' + vX2' = 1.60vY1' + vY2' = 0.934speed1' + speed2' = 2.48093Notice how velocity is conserved but speed is not?
 Evert Member #794 November 2000 If a vector is conserved, then so is its norm. If the velocity vector is conserved, then so must the quantity you call speed (which is the root of the norm of the velocity vector).How are you calculating it?BTW. I've never seen the convention that `speed == magnitude of velocity vector' before. EDIT: I made a slightly different (but easier) analisys than I originally proposed. It is based on the assertion that the momentum can be split in two parts: one along the surface normal at the point of collision, one perpendicular to it.The first changes in the colission, while the latter is not.You can have a look at my (handwritten, beware!) work athttp://gene.science.uva.nl/~eglebbk/twosphere.pngHTH
 Ulf Magnusson Member #2,908 November 2002 As far as I can tell (not very ), orz's code is working fine. If I let go a couple of objects within an enclosed area the system won't speed up or slow down in the unrealistic way it used to.I still find it wierd that the total "speed" needn't be the same before and after the collision though, and I can't grasp how the code does its magic Anyway, thanks, I'll give credits when the final game is released Ulfenstein
 Rash Member #2,374 May 2002 Evert, you're confusing the relative velocity with the sum of velocities. Obviously, a constant sum of velocities does not imply a constant sum of speeds (like Orz's calculation demonstrates). A dramatic demonstration of this is when two perfectly inelastic objects collide head-on. Total speed goes from positive to zero.BTW, if the collisions ARE elastic then there is an additional constraint of the sum of the squares of the speeds remaining constant.
 Andrew Ellem Member #2,835 October 2002 I posted the following formula before, and it has a stupid mistakes (that orz pointed out). Here's the fixed one:The proper formula would be:v1' = ((m1 - m2) / (m1 + m2)) * v1v2' = ((2 * m1) / (m1 + m2)) * v1Ulf, you're comment about collisions not always conserving momentium is somewhat true. The formulas discussed are for single point masses, so all collisions will always be direct ones. If you want indirect collisions (hitting at an angle) you would need to find the angle of collision and deal with the transfer of force, taking the dot product of the vectors to determine how much force is transfered.
 Evert Member #794 November 2000 Quote:Evert, you're confusing the relative velocity with the sum of velocities. Ehm... I don't think so. Where am I doing that?Quote:Obviously, a constant sum of velocities does not imply a constant sum of speeds (like Orz's calculation demonstrates). I'll reiterate what I said above and try to make more clearly what I meant. It seems there is a confusion between two things here.I said that if the velocity vector is conserved, then so is its norm (I won't call it speed, since that is confusing to me).What I did not (mean) to claim is that the sum of norms of individual velocities is conserved. As far as I know, this sum has no physical meaning anyway, so it doesn't matter.Quote:A dramatic demonstration of this is when two perfectly inelastic objects collide head-on. Total speed goes from positive to zero. Obviously. The same holds for any other system that has energy dissipation. I don't think I ever claimed otherwise, as the case we were discussing involves elastic collision.Quote:BTW, if the collisions ARE elastic then there is an additional constraint of the sum of the squares of the speeds remaining constant. This is the same as I said above: the total velocity vector is conserved, therefor, so is its norm (and therefor also the squared norm).Quote: Ulf, you're comment about collisions not always conserving momentium is somewhat true. The formulas discussed are for single point masses, so all collisions will always be direct ones. If you want indirect collisions (hitting at an angle) you would need to find the angle of collision and deal with the transfer of force, taking the dot product of the vectors to determine how much force is transfered. I think the calculations I made (follow the link in my previous post if you want to see them) cover this case for two spheres. I'd be interested in some comments, though orz Member #565 August 2000 Andrew Ellem:That's still not right. It still violates symmetry, and it doesn't factor in object 2s velocity. Evert:If masses are equal and collisions are elastic, then these statements are true:1. magnitude(vel1 + vel2) == magnitude(vel1'+vel2')2. magnitude(vel1) ^ 2 + magnitude(vel2) ^ 2 == magnitude(vel1') ^ 2 + magnitude(vel2')And this statement, which Ulf Magnusson believed to be true, is actually not true:3. magnitude(vel1) + magnitude(vel2) == magnitude(vel1') + magnitude(vel2')That's all I've been saying. And #2 does not follow from #1. In fact, #1 and #2 combined with knowledge of the direction in which force is applied is sufficient information to calculate the answer for all cases that satisfy the conditions (no spin, elastic collisions, equal mass). edit: removed typo (changed "inelastic" to "elastic" above.
 Evert Member #794 November 2000 Ehm... it looks like we have been essentially saying the same thing to each other, except in wording that caused some confusion (at least for me).However, I think I disagree now Your #1 is conservation of momentum, while #2 is conservation of kinetic energy. #2 does not hold in inelastic collissions, since some of the kinetic energy is converted to heat.I should probably make a demo program to test the equations I derived on paper, but I don't have time at the moment (studying for an exam tomorrow::))
 Rash Member #2,374 May 2002 Quote: If masses are equal and collisions are inelastic then these statements are true: I believe orz made a mistake here and meant to say elastic. After all he does so later: Quote: In fact, #1 and #2 combined with knowledge of the direction in which force is applied is sufficient information to calculate the answer for all cases that satisfy the conditions (no spin, elastic collisions, equal mass).
 Andrew Ellem Member #2,835 October 2002 Ugh, my physics is really rusty. Actually it's s more like my basic algebra is rusty... hmm, probably closer to broken. I appologize for posing such half-baked responses. I got the two conservation formulae from my head, but just copied the final from the web.You're completely right. The formula I gave assumes that object 2 is initially at rest. So, yeah, it's no good. But it should be simple enough to just compute the correct formula using the two conservation formulae.
 Evert Member #794 November 2000 Quote:You're completely right. The formula I gave assumes that object 2 is initially at rest. So, yeah, it's no good. But it should be simple enough to just compute the correct formula using the two conservation formulae. Or just do a coordinate transform to a frame where it isn't at rest.
 Ulf Magnusson Member #2,908 November 2002 Ok.. I've gotten a bit further on my game engine and am about to implement damage. When an object hits the player spaceship, I want the resulting damage to be directly proportional to the "force" in the collision. I realize that in the real world it wouldn't be a totally elastic collision if the spaceship aquired damage, but ignore that aspect.How would you correctly calculate this "impact force" (getting the formula might help me understand the collision code better as well. I grew kinda tired of ball collisions and haven't looked at the code since I copied Orz )?Ulfalizer
 spellcaster Member #1,493 September 2001 You could use the difference between the absolute speed before the collision and the absolute speed after the collision.While this is not really correct, it should give you a nice estimation. And since you need to know these two values anyway, it's also pretty simple to implement. --There are no stupid questions, but there are a lot of inquisitive idiots.
 Evert Member #794 November 2000 Check my calculations. I think you'll find your answer basically in them.You need the projection of the momentum vector along the surface normal at the point of collission.
 1   2  Go to: Allegro Development Installation, Setup & Configuration Allegro.cc Comments Off-Topic Ordeals The Depot Game Design & Concepts Programming Questions Recent Threads