Suppose that I have a closed and convex polyhedron given by the following vertices:
$(0.5, 0.5, 0), (0.25, 0.5, 0.25), (0.75, 0, 0.25), (0.75, 0.25, 0)$
Unless I'm wrong, the barycentre (which is the geometrical centroid) shall be computed by averaging the the vertices, which in this case yields the following vector:
$c=(9/16,5/16,1/8)$
I'm running this simple line on Mathematica:
RegionCentroid[Polygon[{{0.5, 0.5, 0}, {0.25, 0.5, 0.25}, {0.75, 0, 0.25}, {0.75, 0.25, 0}}]]
Which delivers the following vector as the region centroid:
$c^\prime = (0.555556,0.305556,0.138889)$
Of course, $c \neq c^\prime$. Can anybody please tell me what I am missing here? Why is it the case that $c=c^\prime$? I assume that, since I'm new in Mathematica, I'm using RegionCentroid
incorrectly, but I can't see how.
Answer
Under details and options of RegionCentroid documentation:
The centroid is effectively given by Integrate[{x1, x2, ...}, {x1, x2, ...} in reg]/RegionMeasure[reg]
For example,
p = Polygon[{{0.5, 0.5, 0}, {0.25, 0.5, 0.25}, {0.75, 0, 0.25}, {0.75,0.25, 0}}];
Integrate[{x, y, z}, {x, y, z} ∈ p]/RegionMeasure[p]
{0.555556, 0.305556, 0.138889}
Comments
Post a Comment