1

I'm researching how to find the inertia for a 2D shape. The contour of this shape is meshed with several points, the x and y coordinate of each point is already known.

I know the expression of Ixx, Iyy and Ixy but the body has no mass. How do I proceed?

Linus Juhlin
  • 1,175
  • 10
  • 31
liquid-snake
  • 73
  • 1
  • 9
  • I think you are confusing area moment `INT(y^2 dA)` with mass moment of inertia `INT(ρ (y^2+x^2) dA)`. Please provide more details of how this is going to be used and what steps you already have. If it has no mass then it has no mass moment of inertia. But it will have area moment (used for bending stiffness). – John Alexiou Jan 11 '17 at 21:30
  • Hay ja72, and thanks for your help, actually my system is oscillating and my objetif is to use the moment of inertia to found the rotation axis, my system are in 2D and I have the coordinate of all the points of his perimeter but nothing in his are, and he don't have any mass. – liquid-snake Jan 12 '17 at 09:19
  • MMOI doesn't go into the calculation for the rotation axis. Maybe you can ask [Physics.SE] first to get the math down, and then ask [SO] for help with the algorithm. See [Instant Axis or Rotation](http://physics.stackexchange.com/a/256856/392) for the way to find the rotation point from the motion. – John Alexiou Jan 12 '17 at 13:39
  • Or maybe ask [Mathematics.SE] on finding the area, centroid & and area polar moment of a triangle. Then split your shape into triangles and add them up with the rules of composition. – John Alexiou Jan 12 '17 at 13:50

2 Answers2

3

For whatever shape you have, you need to split it into triangles and handle each triangle separately. Then in the end combined the results using the following rules

Overall

% Combined total area of all triangles
total_area = SUM( area(i), i=1:n )
total_mass = SUM( mass(i), i=1:n )
% Combined centroid (center of mass) coordinates
combined_centroid_x = SUM( mass(i)*centroid_x(i), i=1:n)/total_mass
combined_centroid_y = SUM( mass(i)*centroid_y(i), i=1:n)/total_mass
% Each distance to triangle (squared)
centroid_distance_sq(i) = centroid_x(i)*centroid_x(i)+centroid_y(i)*centroid_y(i)
% Combined mass moment of inertia
combined_mmoi = SUM(mmoi(i)+mass(i)*centroid_distance_sq(i), i=1:n)

Now for each triangle.

Consider the three corner vertices with vector coordinates, points A, B and C

a=[ax,ay]
b=[bx,by]
c=[cx,cy]

and the following dot and cross product (scalar) combinations

a·a = ax*ax+ay*ay
b·b = bx*bx+by*by
c·c = cx*cx+cy*cy
a·b = ax*bx+ay*by
b·c = bx*cx+by*cy
c·a = cx*ax+cy*ay
a×b = ax*by-ay*bx
b×c = bx*cy-by*cx
c×a = cx*ay-cy*ax

The properties of the triangle are (with t(i) the thickness and rho the mass density)

area(i) = 1/2*ABS( a×b + b×c + c×a )
mass(i) = rho*t(i)*area(i)
centroid_x(i) = 1/3*(ax + bx + cx)
centroid_y(i) = 1/3*(ay + by + cy)
mmoi(i) = 1/6*mass(i)*( a·a + b·b + c·c + a·b + b·c + c·a )

By component the above are

area(i) = 1/2*ABS( ax*(by-cy)+ay*(cx-bx)+bx*cy-by*cx)
mmoi(i) = mass(i)/6*(ax^2+ax*(bx+cx)+bx^2+bx*cx+cx^2+ay^2+ay*(by+cy)+by^2+by*cy+cy^2)

Appendix

A little theory here. The area of each triangle is found using

Area = 1/2 * || (b-a) × (c-b) ||

where × is a vector cross product, and || .. || is vector norm (length function).

The triangle is parametrized by two variables t and s such that the double integral A = INT(INT(1,dx),dy) gives the total area

% position r(s,t) = [x,y]
[x,y] = [ax,ay] + t*[bx-ax, by-zy] + t*s*[cx-bx,cy-by]

% gradient directions along s and t
(dr/dt) = [bx-ax,by-ay] + s*[cx-bx,cy-by]
(dr/ds) = t*[cx-bx,cy-by]

% Integration area element
dA = || (dr/ds)×(dr/dt) || = (2*A*t)*ds*dt
%
%   where A = 1/2*||(b-a)×(c-b)||

% Check that the integral returns the area
Area = INT( INT( 2*A*t,s=0..1), t=0..1) = 2*A*(1/2) = A

% Mass moment of inertia components

         /  /  /  | y^2+z^2  -x*y    -x*z   |
I = 2*m*|  |  | t*|  -x*y   x^2+z^2  -y*z   | dz ds dt
        /  /  /   |  -x*z    -y*z   x^2+y^2 |

% where [x,y] are defined from the parametrization
John Alexiou
  • 28,472
  • 11
  • 77
  • 133
  • Thanks ja72, I wiil try it, in centroid_x(i) should be `centroid_x(i) = 1/3*(ax + bx + cx)`. why there is no mass distribution ? – liquid-snake Jan 13 '17 at 10:56
  • You need an area density to convert area to mass. If the objects have constant thickness `t` then `mass = rho*t*area` where `rho` is mass density (mass/volume). In the above code multiply by `rho(i)*t(i)` each area to get each mass. See post edits – John Alexiou Jan 13 '17 at 12:43
  • Thanks ja72, I tried your algorithm but it gives me `mmoi(i)=0` as I have a 2D shape centred over (0,0), so I choose `a=[x_centerofmass,y_centerofmass] ; b[x(i),y(i)] ; c[x(i+1),y(i+1)]` did I misunderstood something ? – liquid-snake Jan 13 '17 at 13:00
  • If `a=[0,0]` and `b=[bx,by]` and `c=[cx,cy]` then `mmoi = m/6*(bx^2+bx*cx+by^2+by*cy+cx^2+cy^2)` when you expand out the components. That should _not_ be zero. – John Alexiou Jan 13 '17 at 14:32
  • I have edited the answer when `a=[ax,ay]` to show the general expression by component. – John Alexiou Jan 13 '17 at 14:38
  • Hay ja72, Thanks again for your kindly help, actually it was my mistake, I'm using C++, so the mistake was `1/6=0 || 1./6.=0.333` lol sorry. One (another) question, why not calculating the matrice element `Ixx, Ixy, Iyy` for each triangle, then combine them for the total shape ? – liquid-snake Jan 13 '17 at 16:43
  • I thought this is a 2D problem. Only rotation about _z_-axis is important `I_z = INT( x^2+y^2,dm)`. How would you use `I_xy` for example? – John Alexiou Jan 13 '17 at 18:29
  • Integer division will get you every time. – John Alexiou Jan 13 '17 at 18:30
  • Hay Ja72, and sorry for the delay, `Ixx = INT(y²,dm) ; Ixy = INT(x²,dm) and Ixy = -INT((x*y),dm)` then calculating the eigen-vectors in order to find the rotation axis, am I right ? – liquid-snake Jan 16 '17 at 09:25
  • tha Matrice of Inertia that you use for each triangle is that this one ? : `I = INT(y²,dm) ; INT(-y*x,dm) ; 0 \ INT(-y*x,dm) ; INT(x²,dm) ; 0 \ 0 ; 0 ;INT(x²+y²,dm)` – liquid-snake Jan 16 '17 at 12:41
  • I understand now. You need to find the orientation of the principal axes for a polygon. I'll think about it now. – John Alexiou Jan 16 '17 at 15:12
  • Actually, I have an ellipse shape like in 2D, as you suggest, I decompose it to several triangle, then calculating the `I` matrix of each triangle and sum the matrix using the rule that you gave, I would like to compute the all Matrix components. Please can you show me how you get the `Izz` formula for each triangle, I couldn't found your formula. Thanks again ja72. – liquid-snake Jan 16 '17 at 15:26
  • I did not include it because [SO] does not support math formatting. I suggest you ask the following on [Physics.SE] and link it below so I can answer. **How do I computer the mass moment of inertia tensor components for a prismatic triangle given three vertices and a thickness value** – John Alexiou Jan 16 '17 at 15:57
  • Given `I_xy=INT(-y*x,dm); I_xx=INT(y^2+z^2,dm); I_yy=INT(x^2+z^2, dm)` then the principal axes are at an angle `θ=-1/2*ATAN(2*I_xy/(I_xx-I_yy))`. The components of such are to be determined by another posting. Note that _z_ is always a principal axis, so `I_zz = INT(x^2+y^2,dm)` does not go into your calculation. So my answer above is useless to you right now. – John Alexiou Jan 16 '17 at 16:52
  • Ok, Thanks a lot ja72. – liquid-snake Jan 16 '17 at 17:04
  • See edit for answer now. I added an appendix with the general methodology. – John Alexiou Jan 16 '17 at 17:11
  • Thanks a lot ja72, you were really helpfull, Thanks again. – liquid-snake Jan 17 '17 at 10:18
2

I want to slightly correct excellent John Alexiou answer:

  1. Triangle mmoi algorithm expects corners to be defined relative to triangle center of mass (centroid). So subtract centroid from corners before calculating mmoi
  2. Shape mmoi algorithm expects centroids of each single triangle to be defined relative to shape center of mass (combined centroid). So subtract combined centroid from each triangle centroid before calculating mmoi.

So result code would look like this:

public static float CalculateMMOI(Triangle[] triangles, float thickness, float density)
{
    float[] mass = new float[triangles.Length];
    float[] mmoi = new float[triangles.Length];
    Vector2[] centroid = new Vector2[triangles.Length];
    
    float combinedMass = 0;
    float combinedMMOI = 0;
    Vector2 combinedCentroid = new Vector2(0, 0);
    
    for (var i = 0; i < triangles.Length; ++i) 
    {
        mass[i] = triangles[i].CalculateMass(thickness, density);
        mmoi[i] = triangles[i].CalculateMMOI(mass[i]);
        centroid[i] = triangles[i].CalculateCentroid();

        combinedMass += mass[i];
        combinedCentroid += mass[i] * centroid[i];
    }
    combinedCentroid /= combinedMass;


    for (var i = 0; i < triangles.Length; ++i) {
        combinedMMOI += mmoi[i] + mass[i] * (centroid[i] - combinedCentroid).LengthSquared();
    }

    return combinedMMOI;
}


public struct Triangle
{
    public Vector2 A, B, C;
    
    public float CalculateMass(float thickness, float density)
    {
        var area = CalculateArea();
        return area * thickness * density;
    }
    
    public float CalculateArea()
    {
        return 0.5f * Math.Abs(Vector2.Cross(A - B, A - C));
    }

    public float CalculateMMOI(float mass)
    {
        var centroid = CalculateCentroid()
        var a = A - centroid;
        var b = B - centroid;
        var c = C - centroid;
        
        var aa = Vector2.Dot(a, a);
        var bb = Vector2.Dot(b, b);
        var cc = Vector2.Dot(c, c);
        var ab = Vector2.Dot(a, b);
        var bc = Vector2.Dot(b, c);
        var ca = Vector2.Dot(c, a);
        return (aa + bb + cc + ab + bc + ca) * mass / 6f;
    }

    public Vector2 CalculateCentroid()
    {
        return (A + B + C) / 3f;
    }
}


public struct Vector2
{
    public float X, Y;
    
    public float LengthSquared()
    {
        return X * X + Y * Y;
    }
    
    public static float Dot(Vector2 a, Vector2 b)
    {
        return a.X * b.X + a.Y * b.Y;
    }

    public static float Cross(Vector2 a, Vector2 b)
    {
        return a.X * b.Y - a.Y * b.X;
    }
}
7Bpencil
  • 21
  • 3