Message Boards Message Boards

Avoid weird results when using RegionCentroid[] and MomentOfInertia[]?

Posted 7 years ago

Hi,

I get some weird results when using RegionCentroid[] and MomentOfInertia[] to calculate center of mass and inertial tensor of a polyhedron.

First, I create a simple tetrahedron and calculate its properties:

tetra = Tetrahedron[{{0, 0, 0}, {5, 0, 0}, {0, 4, 0}, {0, 0, 3}}]
N[RegionCentroid[tetra] ]
N[MomentOfInertia[tetra]]

and the results are correct:

{1.25, 1., 0.75}
{{9.375, 2.5, 1.875}, {2.5, 12.75, 1.5}, {1.875, 1.5, 15.375}}

But if I mesh a Tetrahedron using MeshRegion:

tetramesh = MeshRegion[{{0, 0, 0}, {5, 0, 0}, {0, 4, 0}, {0, 0, 3}}, Polygon[{{1, 3, 2}, {1, 2, 4}, {2, 3, 4}, {1, 4, 3}}]];
N[RegionCentroid[tetramesh] ]
N[MomentOfInertia[tetramesh]]

The results are totally wrong:

{1.39904, 1.06571, 0.732373}
{{58.2105, 15.9348, 11.5785}, {15.9348, 78.5599, 9.29808}, {11.5785, 9.29808, 94.7576}}

I also tries another mesh method:

tetramesh2 = MeshRegion[{{0, 0, 0}, {5, 0, 0}, {0, 4, 0}, {0, 0, 3}}, Tetrahedron[{1, 2, 3, 4}]];
N[RegionCentroid[tetramesh2]]
N[MomentOfInertia[tetramesh2]]

And this time, center of mass is correct while inertial tensor is wrong:

{1.25, 1., 0.75}
{{9.06636, 2.31481, 1.73611}, {2.31481, 12.3302, 1.38889}, {1.73611, 1.38889, 14.8688}}

I don't know why there outputs are totally different.

And I want to use Mathematica to calculate the center of mass and inertial tensor of any polyhedrons (import .obj file). But after I try this, I wonder if I can get the right answer.

Please help.

POSTED BY: Yukun Huang

You have to distinguish a tetrehedron which is a solid, and something which just has 'sides' (the boundary):

tetramesh=BoundaryMeshRegion[{{0,0,0},{5,0,0},{0,4,0},{0,0,3}},Polygon[{{1,3,2},{1,2,4},{2,3,4},{1,4,3}}]];
N[RegionCentroid[tetramesh]]
N[MomentOfInertia[tetramesh]]

tetramesh=MeshRegion[{{0,0,0},{5,0,0},{0,4,0},{0,0,3}},Polygon[{{1,3,2},{1,2,4},{2,3,4},{1,4,3}}]];
N[RegionCentroid[tetramesh]]
N[MomentOfInertia[tetramesh]]

For example, the last one has zero volume:

Volume[tetramesh]
0

I'm not sure what the intended behavior is to be honest...

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract