While i wait for newton multibody vehicle to become more improved. I started playing with 2d top-down physics.
I have trouble with implementing angular friction. If i understand right some "friction" negative torque exists which causes objects to stop rotating, the problem is i dont know how to implement it.
This is how i implemented sliding friction, just an example.
- Code: Select all
float earth_gravity_accel = 9.81; //m/s^2
float object_mass = 1000.0f; //kg ~ m
float object_friction_with_ground = 0.9; //scalar unit ~ k
float object_gravity_force = object_mass * earth_gravity_accel; //N ~ Fg
float object_friction_resistance = object_gravity_force * object_friction_with_ground; //N
Vector2 ext_force = ....; //some applied external force
float force_result = .0f;
float ext_force_magnitude = external_force.length();
if(ext_force_magnitude>object_friction_resistance)
{
force_result = external_force.normal().scale(ext_force_magnitude-object_friction_resistance);
}
applyForceToObject(force_result); //just some function
