Sign in to follow this  
Hurp

Having a difficult time with friction

Recommended Posts

I am having a rather difficult time trying to learn how friction would be applied between a ball and a plane. I understand things such as for calculationg acceleration, velocity (well, basic velocity) and updating position, however, when it comes to understanding friction I am having just a difficult time understanding it and applying it. Does anyone have any tutorials about, know a good book or resource where I can learn how to apply friction? I have tried reading several text books, Wikipedia and the stickies for this forum. So far though the concept is just going right over my head.

Share this post


Link to post
Share on other sites
If I wanted a proper introduction to friction I would probably read this Physics and Chemistry of Interfaces. That said don't read it if you only understand basic velocity o-o

I might illustrate the wiki a little further in repeating a few less obvious points
- friction in and of itself is not a fundamental force (very important to know)
- the force of friction is proportional to the force pushing the two surfaces together(within restricted confines which Coulomb was not thinking of at the time)
- if you can calculate the force induced by friction than you can calculate an acceleration, which you have stated as having an understanding
- in direct relation to point number two the amount of surface area interacting on a molecular and atomic level is proportional to this fact hence point two
- also with regards to point two the stronger the force pushing the two surfaces together the more intertwining of molecular components(deeper penetration of molecular components,) this will cause more interference
- more + more = more

I draw this picture:
You have a metal slab 10" thick that is being pushed by a rod at its center point on the appropriate surface to create a perpendicular force to induce movement; the rod has 1" diameter. If the force of the rod is maintained to maintain constant velocity, hence compensating for the force of friction, and the gravity was increased there would come a point where the slab would stop moving and the rod(assuming the rod was invincible and could deliver infinite force to keep moving forward with constant velocity) would push an ingot out of the slab like a punch press.

So if you calculate the force on the mass caused by gravity and multiply that by the coefficient of friction between the two surfaces you should have an empirical approximation of the force which should represent that which may be roughly observed.

Share this post


Link to post
Share on other sites
Well I can say that I understand friction a lot more, however, the problem to me seems logically applying it. The problem is when the object is moving across the x, when friction is applied it is being pushed down on the y. Now to me this make sense because of my algorithm, however, I do not know of a different way (or rather, the correct way) that it should be done.

What I first do is normalize the collision normal, for example the plane collision normal if (0, -1, 0).


D3DXVECTOR3 vSurfaceNormal(0.0f, -1.0f, 0.0f);
D3DXVECTOR3 vSurfaceNormalized;
D3DXVec3Normalize(&vSurfaceNormalized, &vSurfaceNormal);


Than I get the magitude of the velocity because if it is zero than it is kinetic friction but if it s greater than zero is kinetic friction.


float fVelocityMagnitude = sqrt((m_vVelocity.x * m_vVelocity.x) + (m_vVelocity.y * m_vVelocity.y) + m_vVelocity.z * (m_vVelocity.z));


Now both for static and kinetic friction I will do a "vFrictionForce.xyz = -fCoefficient * vCollisionSurfaceNormalized.xyz". I do this because of what if the object is not always moving on a perfectly flat (y) surface.


if(fVelocityMagnitude == 0.0f)
{
float fStaticFrictionCoefficient = 0.7f;

D3DXVECTOR3 vStaticFriction = -fStaticFrictionCoefficient * vSurfaceNormalized;
vFrictionForce = vStaticFriction;
}
else if(fVelocityMagnitude > 0.0f)
{
float fKineticFrictionCoefficient = 0.3f;

D3DXVECTOR3 vKineticFriction = -fKineticFrictionCoefficient * vSurfaceNormalized;
vFrictionForce = vKineticFriction;
}


I than subtract the friction force by the velocity.

This is where the problem is, as my vFrictionForce.y is a greater than zero number, when my x is zero.


m_vVelocity.x -= vFrictionForce.x;
m_vVelocity.y -= vFrictionForce.y;
m_vVelocity.z -= vFrictionForce.z;


Later, I will update the position

object->GetTransform()->_41 += (m_vVelocity.x * dElapsedTime);
object->GetTransform()->_42 += (m_vVelocity.y * dElapsedTime);
object->GetTransform()->_43 += (m_vVelocity.z * dElapsedTime);


What is the correct way of applying friction, such as to prevent the friction force having force on the y (wrong) and having it on the x (correct).

Share this post


Link to post
Share on other sites
Friction is by definition in the opposite direction of movement at the point of contact with a magnitude relative to the normal force. It looks like your calculating the magnitude of friction correctly, but applying it in the direction opposite of the normal rather than opposite to the velocity. Try something like :

Friction Force magnitude = (normalized surface normal) dot (force being applied to object)

acceleration vector = -1 * (velocity vector) * (friction magnitude) / [(velocity magnitude) * mass]


You'll probably also want to put in a check that the friction acceleration magnitude is not greater than the velocity or objects will jitter back and forth instead of coming completely to rest.

Share this post


Link to post
Share on other sites
Quote:
Original post by Alrecenk
Friction is by definition in the opposite direction of movement at the point of contact with a magnitude relative to the normal force. It looks like your calculating the magnitude of friction correctly, but applying it in the direction opposite of the normal rather than opposite to the velocity. Try something like :

Friction Force magnitude = (normalized surface normal) dot (force being applied to object)

acceleration vector = -1 * (velocity vector) * (friction magnitude) / [(velocity magnitude) * mass]


You'll probably also want to put in a check that the friction acceleration magnitude is not greater than the velocity or objects will jitter back and forth instead of coming completely to rest.


Say for static friction, you mean not doing


D3DXVECTOR3 vStaticFriction = -fStaticFrictionCoefficient * vSurfaceNormalized;


and instead doing


D3DXVECTOR3 vStaticFriction = fStaticFrictionCoefficient * vSurfaceNormalized;


I was making it -fStaticFrictionCoefficient because it is always in the direction against the motion the object is being forced towards

I removed the m_vVelocity.xyz -= vFrictionForce.xyz and decided to go with the way you suggested, however, the vVelocity is continuing to increase and never increase. Did I maybe mistype something?


fMass = 0.1f;
fFrictionForceMagnitude = D3DXVec3Dot(&vSurfaceNormalized, &vFrictionForce);

// Update position
D3DXVECTOR3 vAcceleration = -1 * m_vVelocity * fFrictionForceMagnitude / (fVelocityMagnitude * fMass);
m_vVelocity = m_vVelocity + vAcceleration * dElapsedTime;
object->GetTransform()->_41 += (m_vVelocity.x * dElapsedTime);
object->GetTransform()->_42 += (m_vVelocity.y * dElapsedTime);
object->GetTransform()->_43 += (m_vVelocity.z * dElapsedTime);


Share this post


Link to post
Share on other sites
Quote:
Original post by Hurp
I was making it -fStaticFrictionCoefficient because it is always in the direction against the motion the object is being forced towards

Friction is in the opposite direction of the direction the object is moving not the opposite direction of the force that is being applied. The "applied force" is probably just the force of gravity, so something like < 0, -9.8 * mass, 0>. Depending on which way the surface normal is facing you might get an unwanted negative sign in that dot product so I'd throw in an absolute value on the magnitude calculation. Also, I left out the coefficient so you'll probably want to put that back in. I don't see anything else wrong, but it's 3:30 AM here and I misspelled "you're", so I'm not exactly alert. I'll look at it again tomorrow.




fMass = 0.1f;
fFrictionForceMagnitude = abs(staticfrictioncoefficient* D3DXVec3Dot(&vSurfaceNormalized, {0, -9.8 * mass, 0} ) );


Share this post


Link to post
Share on other sites
Alright, well everything looks to be looking correctly and I understand all of it besides the acceleration calculation, I was wondering where you picked that up from or could explain it more

acceleration vector = -1 * (velocity vector) * (friction magnitude) / [(velocity magnitude) * mass]

Also, to prevent jittering I do a


if(fFrictionForceMagnitude > fVelocityMagnitude)
{
fFrictionForceMagnitude = 0.0f;
m_vVelocity = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
}


in my ApplyFriction to get a zero acceleration/velocity. However, on the second time through it turns velocity to (#-1.DEF, #-1.DEF, #-1.DEF). I was just going to just move my Update to be like this, but I was wondering if you had a better suggestion.


if(fFrictionForceMagnitude <= fVelocityMagnitude)
{
D3DXVECTOR3 vAcceleration = -1 * m_vVelocity * fFrictionForceMagnitude / (fVelocityMagnitude * fMass);
m_vVelocity = m_vVelocity + vAcceleration * dElapsedTime;

object->GetTransform()->_41 += (m_vVelocity.x * dElapsedTime);
object->GetTransform()->_42 += (m_vVelocity.y * dElapsedTime);
object->GetTransform()->_43 += (m_vVelocity.z * dElapsedTime);
}


Thank you for all of the help =)

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