Physics of 2d object collisions using f=ma???

Blitz3D Forums/Blitz3D Beginners Area/Physics of 2d object collisions using f=ma???

ralphy(Posted 2004) [#1]
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.


Rob Farley(Posted 2004) [#2]
http://can-do.com/uci/ssi2001/newtonsphysicsnb.html

http://www.myphysicslab.com/


ralphy(Posted 2004) [#3]
Thanks Rob.

I think the bumper car section has all the info I need.


eBusiness(Posted 2004) [#4]
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.


_PJ_(Posted 2004) [#5]
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 )


SwedishChef(Posted 2004) [#6]
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.


ralphy(Posted 2004) [#7]
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


StOrM3(Posted 2004) [#8]
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


Michael Reitzenstein(Posted 2004) [#9]
Using kinetic energy doesn't work - you have the *magnitude* of their velocities, but not their velocities themselves!


Stevie G(Posted 2004) [#10]
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 .....


Michael Reitzenstein(Posted 2004) [#11]
Stevie, actually it's the same as

2 * vcmy - debris\vx


eBusiness(Posted 2004) [#12]
ralphy, your method doesn't seem to be totally correct, here is an example where it is quite obvious that something is wrong: