Physics of 2d object collisions using f=ma???
Blitz3D Forums/Blitz3D Beginners Area/Physics of 2d object collisions using f=ma???
| ||
Hi, I need help. Does anyone know of any articles that describe how to calculate the velocities of 2 collided bodies taking account of their objects mass, etc? I.e. similar to colliding asteroids in space. Cheers, Ralphy. |
| ||
http://can-do.com/uci/ssi2001/newtonsphysicsnb.html http://www.myphysicslab.com/ |
| ||
Thanks Rob. I think the bumper car section has all the info I need. |
| ||
Just a guess: if a collide with b then: vb=vb+( (va-vb) on (a to b) )*2*(mass a)/( (mass a)+(mass b) ) va=va+( (vb-va) on (b to a) )*2*(mass b)/( (mass b)+(mass a) ) va and vb is the movement vectors. I hope you know vector math Anyway, just a wild guess ;) Edit: Oh by the way, while I keep guessing, I guess this, if true, should only apply to completely hard balls, or circles in 2D. |
| ||
Velocities is usually best calculated with momentum and kinetic energy equations... mv = momentum (m(v^2))/2 = K.E. In a system, the total energy will be preserved. KE1a + KE1b = ( KE2a + KE2b ) |
| ||
Malice... not really... If the collision is elastic, both momentum and KE is conserved. If the collision is inelastic, momentum is conserved whilst KE is not. In other words, momentum is always conserved, KE is sometimes conserved. I assume though that in a game-world you'll have all collisions be elastic. Therefore it'll be easy to calculate the resultant velocities as both KE and momentum is conserved. |
| ||
Using the conservation of momentum equation worked great (thanks Rob for the myphysicslab link). If anyone is interested, this is the code I ended up with and it works perfectt: (debris is object1, others is object2) vcmy = ( (debris\mass*debris\vy) + (others\mass*others\vy) ) / (debris\mass+others\mass) debris\vy = -(debris\vy - vcmy) + vcmy debris\vx = -(debris\vx - vcmx) + vcmx vcmx = ( (debris\mass*debris\vx) + (others\mass*others\vx) ) / (debris\mass+others\mass) others\vx = -(others\vx - vcmx) + vcmx others\vy = -(others\vy - vcmy) + vcmy |
| ||
Whoa, you guys rock, I know nothing about physics.. pretty sad actually since 99% of games you create need physics. Although I am thoroughly impressed with the brain power on this forum. Kudos! Ken |
| ||
Using kinetic energy doesn't work - you have the *magnitude* of their velocities, but not their velocities themselves! |
| ||
Ralphy, debris\vx = -(debris\vx - vcmy) + vcmy is just the same as debris\vx = -debris\vx Obviously, I haven't seen all your code here but all you seem to be acheiving is making the debris and the object bounce off each other with the reverse of their current velocity. The Mass of the debris or other should make no difference? If it seems to work for you ..... |
| ||
Stevie, actually it's the same as 2 * vcmy - debris\vx |
| ||
ralphy, your method doesn't seem to be totally correct, here is an example where it is quite obvious that something is wrong: |