I came across puzzling results for certain 3D meshes, which I reduced to a minimal case. I made a 1-2-3
cuboid in Blender, exported it to this OBJ file, then imported it to Mathematica, which generates a plausible result:
(rawBlenderCuboid =
Import["https://filebin.ca/3TcNMJskChjW/one_two_three_cuboid.obj"]) // InputForm
MeshRegion[{{1., -3., -2.}, {1., -3., 2.}, {-1., -3., 2.}, {-1., -3., -2.0000009536743164}, {1., 3., -1.9999990463256836}, {-1., 3., -2.}, {-1., 3., 1.9999990463256836}, {0.9999989867210388, 3., 2.0000009536743164}}, {Polygon[{{1, 3, 4}, {5, 7, 8}, {1, 8, 2}, {2, 7, 3}, {3, 6, 4}, {5, 4, 6}, {3, 1, 2}, {7, 5, 6}, {8, 1, 5}, {7, 2, 8}, {6, 3, 7}, {4, 5, 1}}]}]
This has no defects according to FindMeshDefects
. It has the expected area of $88=2*(2*4+4*6+6*2)$:
Area[rawBlenderCuboid]
Its volume, however, is zero
Volume[rawBlenderCuboid]
0
it should be $48$, as is found for the bounding region:
Volume[BoundingRegion[rawBlenderCuboid]]
48.
Its moment of inertia is inexplicable
MomentOfInertia[rawBlenderCuboid]
{{541.333, 7.56979*10^-6, -0.0000177622}, {7.56979*10^-6, 242.667, -0.0000184774}, {-0.0000177622, -0.0000184774, 421.333}}
A hand calculation with unit density leads one to expect $(208, 80, 160)$ for the principal components of moment of inertia, which is indeed found for the bounding region:
MomentOfInertia[BoundingRegion[rawBlenderCuboid]]
{{208., -7.10543*10^-15, -5.32907*10^-15}, {-7.10543*10^-15, 80.0001, 1.15463*10^-14}, {-5.32907*10^-15, 1.15463*10^-14, 160.}}
Bounding regions seem always to be cuboids, so they are not acceptable for my real examples, which are not convex. Therefore, the rather nice solutions from this SE post about convex hulls would not serve.
A clue comes from the fact that Mathematica does not find the mesh to be solid:
SolidRegionQ[rawBlenderCuboid]
False
whereas the bounding region is reckoned as solid:
SolidRegionQ[BoundingRegion[rawBlenderCuboid]]
True
Both the bounding region and the raw region are both valid regions according to MeshRegionQ
, and they're both embedded in 3 dimensions:
RegionEmbeddingDimension[rawBlenderCuboid]
3
RegionEmbeddingDimension[BoundingRegion[rawBlenderCuboid]]
3
so it's not easy to see the more profound differences between them.
These examples from Wolfram's curated collections also have zero volume and are not solid.
I realize from this SE post that I can fit tetrahedra and get to a volume that way, or that I could implement integrals inside polyhedra using a source like this one. Either approach is considerable work, and I wonder whether I am just missing some really simple answer already done in Mathematica. I also think that the approaches documented here for parametric and procedurally generated meshes would not be of direct help. This is my first foray into the new mesh functions, so I am a long way from mastery.