Sign in to follow this  
someboddy

Calculating the normal force

Recommended Posts

If I have two physical bodies colliding, how do I calculate the normal force(it's power. direction is easy)? I don't need code - only theory.

Share this post


Link to post
Share on other sites
Hi,

To begin -- and if it seems like I'm nitpicking, sorry about this -- forces have magnitudes, not powers. Power is the time derivative of energy, and a different concept. Anyway, that out of the way...

Very often, physics engines don't really work directly with "forces." Rather they work with "impulses." Impulse is the integral of force over time. You can think of it as a single "kick" that causes a certain change in momentum.

If what you're interested in is elastic collisions (collisions which don't lose any energy as heat), then you can figure this out using conservation of energy and conservation of momentum. Basically the total kinetic energy of the system (sum of kinetic energies of the bodies) needs to be the same after the collision as it is before; likewise for the momenta. Wikipedia describes this here in 1-d; you'll probably be able to work it out in 2d or 3d yourself. In 2d or 3d, the way to work the problem is to work separately with the x and y components of the momenta. After you work this out, this will give you the (equal and opposite) impulse to apply to each body.

Notice that in all this, you don't really worry about "how long" a collision takes, or "what the force is," because, really, you're modeling the event as happening instantaneously and with infinite force!

If you want inelastic collisions, then things get a little bit trickier. You'll need to deal with the coefficient of restitution, which tells you something (indirectly) about how much energy is lost in the collision.

Cheers!

Share this post


Link to post
Share on other sites
Hey, just happened to run across this post and realized I just finished working out the same problem myself in a little physics demo I've been playing with. I store the momentum of individual bodies as mass, velocity, and direction between frames and pass the time between frames as the time scale (dT). Code for collisions pasted below:


public void DoCollision(CircularObject Neighbor, double dT)
{
//testMove loads the new location in to PointD vector
testMove(dT);
Neighbor.testMove(dT);

double mytheta = 0, myforce = 0, othertheta = 0, otherforce = 0;

//if neither happened, don't bother calculating collision forces
if(getDistance(vector, Neighbor.vector) < radius + Neighbor.radius)
{
//ApplyGravity(Neighbor, -1 * dT);
//Neighbor.ApplyGravity(this, -1 * dT);

mytheta = getAngleToObject(Neighbor);
//Cosine of the angle of attack (direction - angle to neighbor) is the proportion of energy to transfer when two circles collide
myforce = Math.Cos(direction - mytheta) * mass * velocity / dT;//F=m*a, a=v/t => F=m*v/t
othertheta = Neighbor.getAngleToObject(this);
otherforce = Math.Cos(Neighbor.direction - othertheta) * Neighbor.mass * Neighbor.velocity / dT;

if(myforce > 0)
{
applyForceVector(-1 * myforce, mytheta, dT);//-1 here is to subtract the force
Neighbor.applyForceVector(myforce, mytheta, dT);
}

if(otherforce > 0)
{
applyForceVector(otherforce, othertheta, dT);
Neighbor.applyForceVector(-1 * otherforce, othertheta, dT);

}

ApplyGravity(Neighbor, dT);//this should cancel the gravity vector that's already been applied, since we just bounced off
Neighbor.ApplyGravity(this, dT);
}
}


The full code is in the tarball here: http://dl.getdropbox.com/u/186933/gravity-0.1.tar.gz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this