Friction acting on a ball (2D)

1. Jul 31, 2012

Xcrypt

Hello, I am a coder trying to build a game 2D rigid body physics engine.
So far I am working with an impulse-based approach and all is going pretty decent.
Everything does it's job, except one thing: friction acting on a rolling ball.

First I will explain how my collision resolution system works and then I will be more specific about the rolling ball.

My collision resolution system:

When a body hits another body, the collision detection system returns some info:
- a contactpoint : P
- a contactnormal : n
- a contacttangent : t

the next step is to resolve the velocities with an impulse-based approach

1) check the relative velocity of both bodies:
Vr = (v0+(w0 X (P-p0)) - (v1+(w1 X (P-p1)))

where
v: velocity of the body,
w: angular velocity of the body,
p: position of the body
X: vector/cross product

2) project Vr on the n & t to find out the relative velocity in contact coordinates
Vr_C.x= Vr ° n
Vr_C.y= Vr ° t

where
°: scalar/dot product

3) find out the required change in velocity along normal due to the collision
dV_C.x = -(1+restitution)(Vr_C.x)

4) find out the required change in velocity along tangent due to (static) friction
dV_C.y = -Vr_C.y

5) find the velocity per impulse applied at contactpoint along n & t
vpi_n= [ [((n X (P-p0))*iit_inv0) X (P-p0)] + 1/m0 + [((n X (P-p1))*iit_inv1) X (P-p1)] + 1/m1 ] ° n
vpi_t= [ [((t X (P-p0))*iit_inv0) X (P-p0)] + 1/m0 + [((t X (P-p1))*iit_inv1) X (P-p1)] + 1/m1 ] ° t

where
iit_inv: inverse moment of inertia tensor
m: mass

6) find the required impulsed we need to apply along n & t
reqI_n = dV_C.x / vpi_n
reqI_t = dV_C.y / vpi_t

7) In the last stage I do some extra fudgy math/physics for dynamic friction.

if(reqI_t > reqI_n*µ)
then reqI_t = reqI_n*µ

else if(reqI_t < -reqI_n*µ)
then reqI_t = -reqI_n*µ

where
µ: friction coefficient

The problem I have with rolling balls
When a ball is rolling over a flat surface, it's Vr_C.y seems to be very close to zero, causing no visible friction to act on the contactpoint.

where
Vr_C.y = (v+(w X (P-p)) ° t

It seems like the v (linear velocity) component and the (w X (P-p) component (linear velocity at P, due to rotation)
cancel each other out.

Have I gone wrong somewhere in my formulas?
How can this be explained?

Thanks for any help.

Last edited: Jul 31, 2012
2. Jul 31, 2012

mikeph

I can't follow the specific symbols, but I'd guess that your program is giving you an answer of no friction because the ball is not slipping along the surface, so there are neither static or dynamic friction acting to slow the ball.

When the ball rolls in this model, it will never stop. This unreal situation arises because we falsely assume the surface is rigid; in reality it is elastic and slightly depressed at the point of contact due to the ball's weight. The ball is therefore constantly rolling slightly up the hill of this depression. The same effect occurs when the elastic ball is compressed along the vertical axis due to its own weight, and the energy of this compression is not recovered when the ball completes a 1/4 roll, by which point it has been compressed in the new vertical direction (the old horizontal). These processes convert linear and rotational kinetic energy into the heat of the objects.

These factors are probably far more effort than they're worth to calculate in your code, so I'd just add a "rolling friction" term in the code, I think it should be proportional to the normal force (but you might want to check this).

You may also have air resistance to slow the ball, which will probably be the dominant mechanism for faster/smoother rolling objects. This is proportional to the velocity squared.

3. Jul 31, 2012

Xcrypt

So, basically, you're saying that due to deformation, the contactNormal I "estimate" in my code is not correct. In reality it would be in a different direction?
But then, is it really friction that stops a ball? This would mean it's actually the collision force (along normal) stopping the ball?

4. Jul 31, 2012

mikeph

It should suffice to change the normal vector to add a horizontal component (without altering the vertical), perhaps one that is 1% of the magnitude of the vertical. I suppose whether it is friction or not is down to your definition of "friction".

I just found the wikipedia article and it has some good explanations:
http://en.wikipedia.org/wiki/Rolling_friction

This includes some real world examples, eg. a steel ball bearing rolling on a steel plate will have 0.1% of the normal force acting in the opposite direction to the velocity.

5. Jul 31, 2012

Thanks :)