# Calculate the kinetic friction velocity vector from the kinetic friction force in a simulation

I am doing (programming) a simple kinematic 2D simulation on blocks. The idea is that the block will have a force applied.

1) From the force and mass I calculate the the acceleration vector (will show just the x dimension, the y dimension is the same):

//F = m * a, a = F / m
block.acceleration.x = block.force.x / block.mass;


2) From the simulation elapsed time dt and acceleration I update the velocity vector:

block.velocity.x = block.velocity.x + block.acceleration.x * dt;


3) From the velocity and time dt I update the position:

block.position.x = block.position.x + block.velocity.x * dt;


Assuming this is correct (but please correct me if I am mistaken) my problem is when I try to simulate the kinetic friction force of magnitude Fk = uk * m * g (where uk is the friction coefficient and the normal is equal to the weight (m * g).

Since kinetic friction is referred as a force, my idea was take this force (actually just its magnitude) and go through the same process as above: force -> acceleration -> velocity. Then remove this velocity magnitude from the block.velocity taking care never to "invert" the block.velocity vector.

//calculate the force (kinetic friction magnitude)
kinetic_friction_force = kinetic_friction_coefficient * block_mass * g;
kinetic_friction_acceleration = kinetic_friction_force / block.mass; //a = F / m


And I stop here because I believe this does not make sense. In this last step I am cancelling out block.mass and that does not look correct.

Any thoughts?

## 1 Answer

The "F" in "F=ma" should always be the net-force.

So, assuming one-dimensional motion with a push force and a kinetic friction force, then (assuming velocity.x > 0 ),

block.velocity.x = block.velocity.x + ( (block.push.x - uk*m*g )/m ) * dt;

More generally, instead of “just the minus-sign”, it would be better to use "minus the sign of velocity.x ". Even better is to use dot-products to handle general motion on the plane.

• I think that your formula is the same as mine. The part: (block.push.x - uk*m*g)/m is equivalent to block.push.x/m - (uk*m*g)/m so in the friction part the mass gets cancelled out and thus my doubt. – matias.g.rodriguez Jun 14 '19 at 1:53
• In this special case (and possibly other special cases), yes, the equations may agree. However, the physics of Newton's second law is that a=F_net/m. There is only one acceleration vector determined by the net-force... and only one velocity-vector determined by the acceleration. It is a physics misconception that each force in a free body diagram leads to its own acceleration. – robphy Jun 14 '19 at 2:04
• Maybe the kinetic friction force is something else. If I do the simulation using this formula the friction won't be affected by the mass, which doesn't make sense. It looks that I should use the uk*m*g part directly on the velocity: Kinetic friction always acts against the (relative) velocity with a magnitude of fk=uk*n. – matias.g.rodriguez Jun 14 '19 at 2:50