Skip to content
Rotational Dynamics
step 1/5

Reading — step 1 of 5

Read

~2 min readCollision Response

Linear + Angular: Putting Bodies in Their Right Form

Real rigid bodies have six degrees of freedom in 3D, three in 2D: two linear (x, y) and one rotational (theta about z). A 2D rigid body's state is:

position    p   (Vec2)
velocity    v   (Vec2)
orientation theta (scalar radians)
angular vel omega (scalar rad/s)
mass        m,  inv_mass = 1/m
inertia     I,  inv_I    = 1/I    (scalar in 2D)

Newton's Second Law - linear and angular

LinearAngular
F = m * atau = I * alpha
a = F / malpha = tau / I
v += a * dtomega += alpha * dt
p += v * dttheta += omega * dt

Torque from a force applied at a point: tau = r x F (in 2D, the cross of two Vec2s is the scalar rx*Fy - ry*Fx). r is the offset from the center of mass to the application point.

Moment of inertia: common 2D shapes

I is the resistance to angular acceleration. For a uniform body in 2D:

ShapeI about center
solid disc (radius r)0.5 * m * r^2
ring / hollow discm * r^2
solid rect (w x h)(1/12) * m * (w^2 + h^2)
thin rod (length L)(1/12) * m * L^2 (about middle)
point mass at dist rm * r^2

Static bodies use inv_I = 0 (infinite inertia — never rotate from applied torque).

Full impulse equation (with rotation)

The complete impulse magnitude at a contact, including angular terms, is the standard form you'll see in Box2D / Bullet:

j = -(1+e) * v_rel . n
    -----------------------------------
    1/m_a + 1/m_b + (r_a x n)^2 / I_a
                  + (r_b x n)^2 / I_b

The (r x n)^2 / I terms are the angular contribution: an off-center hit makes the body spin, which makes it harder to push linearly.

Exercise

Integrate one frame for a 2D rigid body subject to a force at an offset point. Output the new linear + angular state.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…