# What is inertia in a physics engine?

Inertia seems to be useful in a physics engine, so useful that even in Box2DLite, a demo of Box2D it hasn't been omitted.

See this Body class from Box2DLite:

struct Body
{
Body();
void Set(const Vec2& w, float m);

{
force += f;
}

Vec2 position;
float rotation;

Vec2 velocity;
float angularVelocity;

Vec2 force;
float torque;

Vec2 width;

float friction;
float mass, invMass;
float I, invI; //inertia and reverse inertia
};


In the implementation of the class, inertia is set as the mass multipled by something:

I = mass * (width.x * width.x + width.y * width.y) / 12.0f;
invI = 1.0f / I;


What does this formula means ? I understood from wikipedia that Inertia is how much something doesn't want to move but there's not much formulas in this article. Why is it useful in a physics engine ? How is it used in the context of a collision ? Is it compared to other bodies ?

I believe what we're looking at here more specifically refers to rotational inertia and inverse rotational inertia; not to linear inertia (nor inverse linear inertia).

Wikipedia explains that rotational inertia is also known as the moment of inertia. From here you can take a look at Wikipedia's List of Moment of Inertia where the constant integer 12, shows up in a few of the formulas like for the rotational inertia of rectangular plate about its center.

Rotational inertia is useful in the context of simulating a collision in providing a measure to which the object should resist rotation in collisions that have a tangential component. In other words, it provides a measure of how much rotational velocity should be changed due to collisions that can be thought of as bumping up and rubbing against another body.

Inertia is a body's resistance to changes in angular velocity(rotational speed).

Inertia, in game engines is usually fudged a little, but is represented as a 3x3 matrix transform.

that transform is used to change an angular impulse (final angular deltaV = inertia * deltaV). In the case I just outlined, this is actually the inverse inertia transform, or inertia^-1

When you do this it is the same as dividing a linear impulse by the mass of the body.

In your case, using the contact point, you compute the torque (force to induce change in velocity around an axis), and transform it with the inverse inertia, which produces the final change in angular velocity.