Calculating the Moment of Inertia of a non-regular convex Polygon

The moment of inertia is needed to calculate the rotational movement of a body. You can think of it as the rotational equivalent of mass. To calculate the moment of inertia you have to integrate the area (volume in 3D) of the polygon in respect to the rotational axis (most often than not an axis through the center of mass). Integrating is slow and hard to do with an arbitrary polygon, so here is an easy way to do just that.

First the polygon is triangulated by fanning around the centroid (center of mass), so that the centroid is part of every triangle.

convex polygon inertia

triangle inertia

Now the centroid of the triangle and the moment of inertia of the triangle about an axis through the center of mass of the triangle ( try to say that ten times fast in a row) has to be calculated.

convex polygon inertia

But the original polygon rotates about an axis through the centroid of the original polygon, so we have to use the parallel axis rule. The rule states that the moment of inertia about an axis parallel to one through the centroid can be calculated by adding the mass ( in this case we use the area of the triangle as mass) multiplied by the squared shortest distance to the parallel axis.

convex polygon inertia

The last step is to sum-up all moments of inertia of the triangles and you are done.

22 thoughts on “Calculating the Moment of Inertia of a non-regular convex Polygon”

  1. To calculate the ‘mass’ moment of inertia of a polygon you just have to multiply the area with a scalar that represents the density of the polygon, for example 2 [gramm per square meter]. In this method the density is implied to be one.
    Further, the parallel axis theorem works for every axis not only for axis in the plane of the shape. In 2D the only moment of inertia that makes sense to compute is the one about the axis that points out of the screen ( z axis), which is normal to the plane of the polygon and is calculable with the parallel axis theorem as stated above.
    There might be some confusion about the moment of inertia of the triangle which is in respect to the z axis as described, bh^3/36 is in respect to the x axis.
    Wow I wanted this to be a short answer.

  2. Hi there,
    Thanks for the clear and informative article! However, quick question — I think there may be a typo on the equation for I_{triangle}.

    As it is:
    I_{triangle} = 1/36 * (b h^3 – b^2 h a + b h a + b h^3 )

    I think it should be:
    I_{triangle} = 1/36 * (b^3 h – b^2 h a + b h a^2 + b h^3 )

    If I’ve done something silly, I apologize, but I think that’s what it’s supposed to be. Thanks!

  3. Thanks for the tip off. I’m putting an engine together myself and hadn’t researched moment of inertia in the past.

    It’s surprisingly difficult to find good info about it online.

    Where would you place the mass values if you were to use an m variable? I’ve an idea myself, but I haven’t been able verify anything. . . .

    By the way, it seems worth pointing out that you can apply the parallel angle theorem to objects of any distance from the polygon’s centroid, so there’s no mathematical reason to limit yourself to convex polygons. As long as you have a method of triangulation, you can find moment of inertia for any shape you want.

  4. To give a polygon a ‘mass’ you would just multiply the area with a chosen density.
    For example let the polygon be a sqare with a side length of 20 pixel. The area would be 400 pixelsquared [ps] and the mass could be calculated by multiplying the area with a density of the form d [kg/ps].
    The unit of mass isn’t really import but would ease simulating steel or wood by just taking the densities from a source like wikipedia.

    For implementation: the density would just substitute the property mass of the polygon; internally a mass could then be calculated with the method above, or you could still use a mass and calculate the density accordingly.
    Using density the formula given above for the moment of inertia of a triangle would be just multiplied with the density; using mass you would have to factor out b*h/2, the area of the triangle, and substitute this with the mass.
    If you use the second method, there would be no need for a density, but you would have to chose the a arbitrarily mass so that it ‘fits’ the polygon and there would be no direct correlation between area and mass.

    Yes, it should be easy to calculate the moment of inertia of any shape just by substracting the ‘holes’.
    I.e imagine the points A and B in the polygon shown in the article to be missing; the polygon would be concave. Now the fanning would yield a triangle that is not part of the polygon, consisting of the centroid and the neighboring points of A and respectively B.
    The moment of inertia of this triangle can be computed with the method shown above and then has to be substracted form the total moment of inertia.

    Hope that helps!

  5. I went through the calculus for this today. I found the following for the mass moment of inertia of a triangular plate about an axis perpendicular to the plate at the center of mass. It’s not pretty to look at, but it should work. The triangle is defined by three points (x1,y1),(x2,y2),(x3,y3) in Cartesian coordinates.
    I_{triangle} = m/36*(x1*(y3-y2) + x2*(y1-y3) + x3*(y2-y1))*(x1^2 + x2^2 + x3^2 – x1*x2 – x1*x3 – x2*x3 + y1^2 + y2^2 + y3^2 – y1*y2 – y1*y3 – y2*y3)

    For the calculation, I used the definition of the mass moment of inertia. I integrated over a triangle broken into piecewise sections. I used Maple to accomplish this completely symbolically. If this solution looks suspect, here was my input to the program:

    i:=int(int((cx-x)^2+(cy-y)^2,y=h..f),x=x1..x2) + int(int((cx-x)^2+(cy-y)^2,y=h..g),x=x2..x3);

    I then told it to simplify and factor i, producing the equation above. My input to the program assumed that x1

  6. I forgot to explain the various variables used in my derivation.
    cx and cy are the x and y coordinates of the centroid/center of mass of a triangle.
    f, g, and h are the equations for the 3 edges of the triangle.

  7. The equations for the 3 edges of the triangle and centroid are ok, but there seems to be something off about the integration, and a problem with the sign if the points are given in a wrong order.

  8. I just reread my first post and noticed that the end of it got cut off. What I said was that I assumed that x1

  9. Sorry, my posts were being cut off by my ‘<‘s…

    I just reread my first post and noticed that the end of it got cut off. What I said was that I assumed that x1 < x2 < x3 for the integration. I would have performed it again with a different configuration, but the equation looked relatively symmetric so I didn’t.

    You’re right about the sign switching depending on the order of the points. I vaguely remember something from calculus that has to do with following boundaries clockwise when doing some integrations, but I’m not sure if that applies here. I’ll have to dig up my notes on that.

    Perhaps there would be some merit in testing some numerical integrations against that equation for various triangles. I’ll see about writing a little test program for that.

  10. I went through the calculus myself and came up with the same equation, so I went ahead an used both equations to calculate the moment of inertia of a right angle triangle, and both outcomes were the same.

    I would have to test more to see which one is faster, but basically one equation should be covertable into the other.

    Anyway, thanks for your contribution!

  11. Chris said: “Yes, it should be easy to calculate the moment of inertia of any shape just by substracting the ‘holes’.”

    So I took so long to get back.

    I’ve got a form coded that uses a different method. the idea is the same as yours, but instead of fanning out my triangles from the center of gravity, I’m cutting them arbitrarily and calculating moment of inertia the same way.

    In other words, I’m not subtracting any pieces, I’m just cutting and summing the parts. The parallel axis theorem still applies so the only difference between what I’m doing and yours is the triangulation.

    Just thought it was useful tidbit to put out there for any curious coders.

    -Christopher J. Rock

  12. Hi, I have been doing the same, and then I found this website…
    I think you people may like to know my solution as it is rather elegant (I think):
    I calculate the moment of inertia of a triangle through its center of mass using the medians (the lines from halfway each side to the opposite corners). The center of mass is the crossing point of the three medians; it is at 2/3 of each median. I call the lenght of the medians p,q, and s.
    Now the moment of inertia is: I=M*(p^2+q^2+s^2)/27
    You can find this by deviding the triangle in 4 equal triangles by connecting the mids of the sides and then calculating the moment of inertia in a recursive manner.

    About concave polygons: They are indeed no problem. I call the angles of the polygon A1,A2,A3,… and the center O. Now if the angle A1_O_A2 is positive, you add this triangle, if it is negative you substract it. And so on for each corner. I hope this explanation is understandable… Draw it out and you will see it works perfect!

  13. I was trying to work out the same thing, and adapted an existing 3D method from the Journal of Graphics Tools.
    If you’re interested, I posted the code on my home page, at the bottom. It’s pretty stand-alone, so it should be easy to plug in somewhere if you just want to use it.

  14. Hi,

    I am trying to calculate the inertia tensor for orbitary tetrahedron (p0, p1, p2, p3). anybody have the soluation, please do let me know.

  15. In the comments Sam gives an expression in terms of triangle vertices.
    If we have a triangle v1(0,0), v1(10,0), v3(0,10) then the (b,h,a) formula gives 27777 and the vertices formula gives -27777.
    If we flip the vertex ordering to (0,10), (10,0), (0,0) then the (b,h,a) formula still gives 27777 but the vertex formula is now 27777; ie opposite in sign.
    Thus, the vertex formula is order dependent and if a positive value is always required then the abs() value is required.

  16. gmseed

    to add go counterclockwise.
    to subtract go clockwise.
    you can compute section with a hole in it.


Comments are closed.