Maths behind applyImpulse()

Hi. Many of you may know applyImpulse() function. It allows to apply an external force to an object at any point. It somehow generates both linear force and torque(or just rotation). However, I don’t know the math behind it. Could you tell me how to calculate this manually?

An impulse is the integral of a force over time (that it acts for)
/uploads/default/original/4X/2/6/0/2609dfdb39d332ce9f7f30bc9168d9aa5c7d2089.JPGstc=1
This is the Bullet 2x implementation. It takes the cross product of the position vector and the impulse for the rotation (torque). Ensuring that the angle between the position and pulse is zero will ensure no torque

Attachments


And the force is actually the same? So it’s like the usual force + the torque? OK! Does the torque applied depend on the arm length(impulse point distance from origin)?

Actually - what is m_angularFactor? Also, how does bullet calculate the inertia of different object types? Is it stored as a vector(for each axis), matrix or sth like that?

No, as I said, the impulse is the area under the Force vs Time curve. Its force * time. In effect, applyImpulse (ignore rotation for now) of 10Ns is the same as applyForce of 10N for 1 second, or applyForce of 5N for 2 seconds etc.

The angularFactor is some bullet const.

Torque does depend upon the length - it’s the cross product, defined as |a||b|sin(x) where |a| is the length of a, and x is the angle between a and b

Oh… It’s auto-done in the cross?

“Physics for Game Developers” by David M. Bourg (ISBN 0-596-00006-5) covers all the math behind a physics engine.

For the given bullet code,
The angularFactor allows you to dampen the force in each direction (if defined).

Unless otherwise specified, calculations are relative to center of mass.

The cross gives the direction of torque relative to the object’s center of mass.

Then in apply torqueImpulse the torque vector is multiplied by the object’s current inertia represented by a tensor.