

math behind 3d nonelastic collision

Hello everyone.
Hope this will be usefull for many people :)
First of all excuse me for any language errors ;)
I want to model a 3d collision, to make it simple  between two spheres. As far as i'm concerned i'v got the physics covered
just like in here : thttp://forums.xna.com/forums/t/48719.aspx
1. we need to calculate the angle of collision  the dot product comes handy http://msdn.microsoft.com/enus/library/bb196388.aspx this way we can determine how the object colided
2. we need to find the vector of 'contact' (the one between the centers)
3. as i see it we need to calculate how it coresponds to the momentum/velocity vector of object  this should give us the amount of momentum of object A to be transferred to object B  this probably can be done somehow with the dot product ( can it?)
having the the amounts of momentum to be strnsfered we add them to objects just like it is showned in included above topic.
All of this is fairli simple in 2d, you can do this on paper but when it comes to 3d vectors it gest me a bit confused.
Can someone tell me then, how can I calculate in 3d the amount of Momentum vector that should be applied to another object ?  the number three above.
the other thing that concerns me is how that model will react if one of the objects is static, and even more: has mass sygnificantly greater than the object that hits it. (as i see it the moving object should bounce of, but according to this model no momentum will be applied to him, as the other object is static  it'll statrt to move after the collision)




Re: math behind 3d nonelastic collision

To be honest, it sounds like your model is pretty spot on. Think about the Law of Conservation of Momentum: m_{1}v_{1} = m_{2}v_{2}. It states that when the momentum of one object is applied to another, the amount of momentum is equal and related to mass and velocity. This means when two objects collide nonelastically, they swap momentums.
If one of your objects is static, it has velocity 0 and therefore momentum 0 (since anything times 0 is zero). Now call the static sphere_{1} and call the moving, less massive sphere sphere_{2}. If we say that mass is not lost by either object in the collision, the law above then describes their impact as this:
m_{1}v_{1before} = m_{2}v_{2after} substituting the velocity of the static sphere leads to m_{1} * 0 = m_{2} * v_{2after} implying that v_{2after} = 0
m_{2}v_{2before} = m_{1}v_{1after }solving for v_{1after} leads to v_{1after }= (m_{2}v_{2before}) / m_{1 }!= 0 since v_{2before} != 0
So, the lesson here is, no matter how big the static one is, and no matter how slow the moving one is, they always switch when they hit. To clarify though, the magnitude of a vector (in any number of dimensions) is square root of the sums of the components squared:
x = sqrt(x * x) < you might have noticed x is the same notation as absolute valueno accident
(x, y) = sqrt(x * x + y * y)
(x, y, z) = sqrt(x * x + y * y + z * z)
.
.
.
And the angle, well that's much more complicated and I can't quite think of it at the moment. If you need to know, reply, and I'll look into it.




Re: math behind 3d nonelastic collision

Yes, you have the physics down pretty good. The way I did it when I made this learning project was to convert my momentum vectors from an (X, Y, Z) coordinate system to a ('collisionNormal', BiNormal, 'Tangent') system to resolve collisions. That's kind of my own nomenclature and I didn't concern myself with the bN because pool is essentially a 2d endeavor as far as linear motion is concerned . My 'collisionNormal' is the same as your 'vector of contact'. I converted them just like you with the dot product.
So now you have a cN component of the momentums.
Azrael pl: Can someone tell me then, how can I calculate in 3d the amount of Momentum vector that should be applied to another object ?
Both balls must lose there cN components as they can no longer travel 'into' each other anymore, yet 'conservation of energy' requires no loss of combined momentum here. It turns out that as in real life they simply swap cN components. They give up their energy in that direction to each other. This is not dissimilar to simply negating an x or y value in 2d to 'bounce' a ball off a wall. Once swapped, convert momentums back to (X,Y, Z) coordinate system.
Azrael pl: the other thing that concerns me is how that model will react if one of the objects is static, and even more: has mass sygnificantly greater than the object that hits it.
Now the new momentum divided by mass gives a new velocity in the proper direction. Proper velocity works itself out if you store and manipulate momentum. Per Newton: velocity = momentum / mass. If before the collision, the momentum was zero, after collision it will be in the direction of the other balls cN. If heavy mass, velocity will be low, if light mass, velocity will be fast.
If it helps, here is the code from the pool game I made... (go easy on me.. I used the word 'lineal' when I meant 'linear' :)... * embarrassed* ). Also, since pool on a flat level surface is essentially a 2d operation, the 3rd component wasn't needed for my purposes but if you convert the 3d vector from xyz to cN,bN,T, ultimately, you would still just swap cN components like I did & convert back.




Re: math behind 3d nonelastic collision

Wow, tank you both very much.
I've never got such good answers in such a short time :)
I'll try to adapt Steves code(thanks again there:)), but from what i've already noticed, is that actually dot product should be used in my 3rd step not in first (between collision normal and momentum of the object). So this is the main thing i was not sure of :)
And Deedub, thanks for reminding me a few things. I also thought about Conservation of Momentum as i think it'll be usefull when in one 'update' I'll detect a collision of more than two objects together. Not keeping track of how many object have been hit would cause a drastic increase in overal energy. At least that's the way i see it :)
When I'll have some results and if the topic won't be closed by that time i'll make you know how it turned out:)




Re: math behind 3d nonelastic collision

Thanks Steve...you finally put me on the right track after Googling and reading a lot of garbish....


