Take the 2-minute tour ×
Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free, no registration required.

I'm building a physics simulator for a graphics course, and so far I have it implementing gravitational and Coulomb forces. I want to add collisions next, but I'm not exactly sure how to go about doing it.

A quick summary of how this is working so far is: All objects are spheres of a set radius, mass and charge. The mass's and charges of the spheres are treated as point charge/mass for the calculation. Every step in time (about 1/50th of a second) the forces acting on each object are calculated in a nice big nested for loop that figures out the coloumb and gravitational force between 2 objects, for every set of 2 objects, and then they are summed together. I use this net force to determine the acceleration, and the rest is fairly obvious from there.

What I want to add in is collisions. I can deteremine pretty easily if a collision is happening (if the distance between them <= radius of one + radius of other), what I am not so certain of is how I should add in the collision force (and would need to do it component wise). I want elastic collisions, though for now I'd just be happy with getting conservation of momentum

The information I have easily available are: the velocity of each object (and I mean velocity, speed and direction), the position of each object, the mass/charge (charge obviously not needed here) and the Net force calculated so far for each object for the next step in time. I dont need exact formulas (would prefer if they arent exact), just need a nudge in the right direction.

share|improve this question
1  
What about spin? Do your objects have spin; do you consider them point-like? –  Eelvex Mar 10 '11 at 20:04
1  
Then, just apply the momentum conservation + kinetic energy conservation to the axis connecting your objects (i.e the axis connecting their centers). –  Eelvex Mar 10 '11 at 20:13
1  
Elastic collision = kinetic energy conserved. Momentum is always conserved. –  Eelvex Mar 10 '11 at 20:17
3  
I think this suffices. –  Eelvex Mar 10 '11 at 20:20
2  
@Eelvex @CJB Be careful with that animation. It shows the balls coming off at right angles, which holds only when the masses are equal. –  Mark Eichenlaub Mar 10 '11 at 20:46

2 Answers 2

Mark Eichenlaub's answer is 100% correct, but you can also do it without changing reference frames, and I think it's probably easier that way. Here's how I would set it up.

Suppose that you've determined that two objects are going to collide within the next time step. Determine the positions of the two objects at the moment of collision. Draw a line connecting their two centers. Determine a unit vector $\hat n$ pointing from the center of object 1 to the center of object 2. During the collision, the force will be in this direction, so only this component of the momentum will change. Let the unknown change in momentum be $\vec q$. This vector points in the $\hat n$ direction: $\vec q=q\hat n$. To be specific, if $\hat n$ points from object 1 to object 2, then $\vec q$ is the momentum gained by object 2, and $-\vec q$ is the momentum gained by object 1.

Now let $\vec p_1,\vec p_2$ be the initial momenta of the two objects, so that the final momenta are $\vec p_1-\vec q,\vec p_2+\vec q$. Energy is related to momentum via the rule $E=p^2/2m$, so conservation of energy says $$ {p_1^2\over 2m_1}+{p_2^2\over 2m_2}={(\vec p_1-\vec q)^2\over 2m_1}+{(\vec p_2+\vec q)^2\over 2m_2} $$ In this expression, you know everything except the magnitude $q$ of $\vec q$. So you can solve this equation for the unknown $q$. Then you can compute the new momenta, and you're done.

The equation you solve ends up being a quadratic, but with no constant term -- that is, it's of the form $$ aq^2+bq=0. $$ One solution is $q=0$, of course, but you don't want that one: it corresponds to the two objects passing right through each other. The nonzero one's the one you want.

share|improve this answer

In an elastic collision between spheres, we can use conservation of energy and momentum, but this alone is not enough.

Start by looking in a frame where one ball is stationary (the target) and the other one is coming in from the side (the striker). The problem is to find the final momenta of the two balls. Assuming everything stays in a plane, there are 4 degrees of freedom - two for each momentum.

Conservation of momentum has two constraints and conservation of energy has one, so applying these still leaves one degree of freedom; one extra parameter is needed to describe the collision. One choice is the precise point of the collision. Because the force is being applied at this point and is only a contact force normal to the surface, the target ball will shoot off in the direction of the normal to the surface at the collision point.

One way to summarize the rules is:

  1. Boost to a reference frame where the target is initially stationary.
  2. Make the final momentum of the target point in the direction of the vector between the balls' centers at the moment of impact.
  3. Apply conservation of kinetic energy.
  4. Apply conservation of momentum in both dimensions.
  5. Boost back to desired original frame.

This should uniquely specify where the target and striking balls go after the collision, and the answer is independent of which ball you choose to be the target.

If you're doing the calculation in 3D, you will have to choose the correct plane. It's the plane spanned by the displacement vector between the balls and their relative velocity. (If these vectors are dependent, the motion is only on a line.)

share|improve this answer
1  
As I wrote in my answer, I think it's easier to do it in the "lab" frame rather than boosting. But if you're going to boost, surely you're much better off boosting to the center-of-mass frame rather than the stationary-target frame. –  Ted Bunn Mar 10 '11 at 20:58
    
though correct and nice, you make it sound much more complicated than it really is. Also, momentum changes only in one dimension: that of the joining axis. –  Eelvex Mar 10 '11 at 21:05
    
@Ted I guess I agree with you. I chose that frame because you can find the direction of the target ball easily, but reading your answer it's clear it would be easier to do it the way you described. –  Mark Eichenlaub Mar 10 '11 at 21:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.