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
//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.