I'm programming a game and I have to find the moment of inertia of a flat polygon (axis of rotation is perpendicular to the polygon, from now on I will call it the point of rotation). My idea was to cut the polygon into n triangles with one vertex at the point of rotation. This should work for all convex polygons where point of rotation lies inside the polygon. I think it should also work with general polygons if you add and substract accordingly but I will investigate that later. For now I'm having trouble calculating the moment of inertia for this triangle. I'm not very good at this.

Let's translate the system so that the point of rotation is at the origin O and call the other two vertices $P_{1}$ and $P_{2}$ and assume that the vertices are counterclockwise. Let's also rotate the system so that the vector $P_{1}$ has no horizontal component.

The moment of inertia, let's call it $I$, should be $I = \rho * \int \int r(x, y)^{2} \partial x \partial y$, assuming constant density. I will drop the density term, assuming a density of $1$.

Using the vector $P_{1}$ and $P_{2}$ as basis, the square distance of a point inside the triangle to the origin is

$r^{2} = (\cos(\delta)\ast v\ast|P_{2}|)^{2} + (u\ast|P_{1} + \sin(\delta)\ast v\ast|P_{2}|)^{2}$

, where $\delta$ is the angle between $P_{1}$ and $P_{2}$.

multiplying that out, I get:

$$r^{2} = \cos^{2}(\delta)\ast v^{2}\ast|P_{2}|^{2} + u^{2}\ast|P_{1}|^{2} + 2\ast\sin(\delta)\ast u\ast v\ast|P_{1}|\ast|P_{2}| + \sin^{2}(\delta)\ast v^{2}\ast|P_{2}|^{2}.$$
Since $\sin^{2}(\delta) + \cos^{2}(\delta) = 1$,

$$r^{2} = u^{2} \ast |P_{1}|^{2} + v^{2} \ast |P_{2}|^{2} + 2 \ast \sin(\delta) \ast u \ast v \ast |P_{1}| \ast |P_{2}|.$$

Since $\sin(\delta) = \frac{P_{1} \times P_{2}}{|P_{1}| * |P_{2}|}$ this is reduced to:

$r^{2} = u^{2}*|P_{1}|^{2} + v^{2}*|P_{2}|^{2} + 2*u*v*(P_{1} \times P_{2})$

The Integral, then, looks like this:

$\int_{0}^{1} \int_{0}^{1-v} u^{2}*|P_{1}|^{2} + v^{2}*|P_{2}|^{2} + 2*u*v*(P_{1} \times P_{2}) \partial u \partial v$

Integrating once:

$$
\begin{array}{mml}
I & = & \int_{0}^{1} [\frac{u^{3} \ast |P_{1}|^{2}}{3} + u \ast v^{2} \ast |P_{2}|^{2} + u^{2} \ast v \ast (P_{1} \times P_{2})]_{0}^{1-v} \partial v \newline
& = &\int_{0}^{1} \frac{(1-v)^{3} \ast |P_{1}|^{2}}{3} + (1-v) \ast v^{2} \ast |P_{2}|^{2} + (1-v)^{2} \ast v \ast (P_{1} \times P_{2}) \partial v \newline
& = & \int_{0}^{1} \frac{(1 - 3 \ast v + 3 \ast v^{2} - v^{3})*|P_{1}|^{2}}{3} + (v^{2} - v^{3}) \ast |P_{2}|^{2} + (v - 2 \ast v^{2} + v^{3}) \ast (P_{1} \times P_{2}) \partial v
\end{array}
$$

Integrating a second time:

$$
\begin{array}{mml}
I & = & [(\frac{v}{3} - \frac{v^{2}}{2} + \frac{v^{3}}{3} - \frac{v^{4}}{12})*|P_{1}|^{2} + (\frac{v^{3}}{3} - \frac{v^{4}}{4})\ast|P_{2}|^{2} + (\frac{v^{2}}{2} - \frac{2\ast v^{3}}{3} + \frac{v^{4}}{4})\ast(P_{1} \times P_{2})]_{0}^{1} \newline
&= &\frac{|P_{1}|^{2} + |P_{2}|^{2} + (P_{1} \times P_{2})}{12}
\end{array}
$$

That's a nice equation. However, it doesn't work. I tried comparing the results with the moment of inertia of a rectangle that rotates around it's center of mass.

The moment of intertia of a rectangle with sides a and b and constant density is

$$
\begin{array}{mml}
I & = & \int_{\frac{-a}{2}}^{\frac{a}{2}} \int_{\frac{-b}{2}}^{\frac{b}{2}} x^{2} + y^{2} \partial x \partial y
\newline
& = & \int_{-\frac{-a}{2}}^{\frac{a}{2}} [\frac{x^{3}}{3} + x\ast y^{2}]_{-\frac{-a}{2}}^{\frac{a}{2}} \partial y \newline
& = & \int_{-\frac{-a}{2}}^{\frac{a}{2}} \frac{b^{3}}{12} + b\ast y^{2} \partial y \newline
& = & [\frac{a^{3}\ast y}{12} + \frac{a\ast y^{3}}{3}]_{-\frac{-a}{2}}^{\frac{a}{2}} \newline
& = &\frac{a^{3}\ast b + a\ast b^{3}}{12}
\end{array}
$$

The moment of a rectangle rotating on it's center has to be the sum of the moment of inertia of it's triangles $I(O, P_{0}, P_{1}) + I(O, P_{1}, P_{2}) + I(O, P_{2}, P_{3}) + I(O, P_{3}, P_{0})$

Using the simplest case of a square with its vertices at the coordinates (1,1), (1,-1), (-1,-1) and (-1,1) the moment of inertia is $\frac{2^{3}\ast2 + 2\ast2^{3}}{12} = \frac{8}{3}$

The moment of inertia of each of it's triangles is $\frac{2+2+2}{12} = \frac{1}{2}$

But $4\ast \frac{1}{2}$ is $2$ not $\frac{8}{3}$.

Where is my mistake?

Later, I also need to find the so-called area moment of rotation. I assumed you just divide the moment of inertia by the area but that doesn't seem to be the case. There is a list on wikipedia, listing many different area moments of inertia, including polygons http://en.wikipedia.org/wiki/List_of_moments_of_inertia. But the equation for the polygon case is not explained at all and I don't want to use formulas that I don't understand. It also doesn't make any sense to me at first glance.