# Moment of inertia of an arbitrary grid of squares with different masses

I'm making a game where the player can create a 2D spaceship, one square "tile" at a time.

In order to simulate the kinematics of the ship I need :

• To compute the CoM vector. That's easy enough : CoM = Σ (m_i * r_i), where r_i is the position vector of each tile relative to the world origin)

• To compute the moment of inertia M of the whole grid.

The second point is where I struggle.

I know that : M = Σ(m_i*r_i²) with r_i being the distance from the axis of rotation (in my case the CoM).

I also know that the moment of inertia of a square of side a (with uniformly distributed mass) is (a^4)/12.

My first attempt was to just compute M as Σ(m_i*r_i²) where r_i² is the distance between the CoM and the center of each tile. However, given a grid of a single tile, this solution gives M=0, when I would expect (a^4)/12.

Could you hint me in the right direction ? I know this seems like an easy problem, but I couldn't find much of anything on the internet.

• This might be something the Physics StackExchange could help with. Commented May 7 at 15:23
• Yeah probably... Anyway I solved it. I'll post an answer for anyone that might need it. Commented May 8 at 11:02

I got it working in the end, so for anyone interested here's the solution :

## General solution

You need to use the parallel axis theorem.

This theorem states that, given a body with a moment of inertia $$\I_{\vec x}\$$ around an axis $$\\vec x\$$ passing through its center of mass, you can calculate the MoI $$\I_{\overrightarrow x'}\$$ of that body around any other axis $$\\overrightarrow x'\$$ that is parallel to $$\\vec x\$$ given the formula :

$$\I_{\overrightarrow x'} = I_{\vec x} + md^2\$$, where:

• $$\m\$$ is the mass of the body
• $$\d\$$ is the distance between $$\\vec x\$$ and $$\\overrightarrow x'\$$

## Solution applied to a grid of tiles

First, I should point out there's a mistake in my original question:

The MoI of a square plate around an axis perpendicular to the plate and passing through its CoM is not $$\\frac {a^4} {12}\$$. Rather its $$\m * \frac {a^2} {6}\$$.

That being said, trying to apply the general solution to the grid case is pretty easy :

The MoI of a single tile in the grid around the CoM of the grid is:

$$\I_t = \frac m 6\ + md^2\$$ (assuming a tile of side 1)

with:

• $$\d\$$ the distance between the CoM of the tile and the CoM of the grid
• $$\m\$$ the mass of the tile

Then, the total MoI of the grid is just the sum of the contribution of each tile:

$$\ I_{grid} = \sum_{i=0}^n = \frac {m_i} 6\ + m_i d_i^2\$$