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:


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.

  • 2
    $\begingroup$ I don't think it's the average of the vertices. Minor quibble: RegionCentroid[ConvexHullMesh[points]] will work when the points form a polyhedron. Your points seem to be coplanar, so they form a polygon. $\endgroup$
    – Michael E2
    Jan 17, 2018 at 17:49
  • $\begingroup$ @MichaelE2 Okai, I got the definition wrong in the first place! By the way, if my points form a closed and convex polytope in $\mathbb{R}^N$, can I still find the centroid with some other function or something? $\endgroup$
    – EoDmnFOr3q
    Jan 18, 2018 at 11:29
  • 1
    $\begingroup$ I don't know a way. I don't think there's a built-in way to find the convex hull or triangulation in dimensions > 3. There's MATLAB function someone wrote, if you have access to MATLAB. $\endgroup$
    – Michael E2
    Jan 18, 2018 at 14:07
  • $\begingroup$ Thank you very much for your comment. I have had access to Matlab in the past, but not anymore. I'm going to ask on this site if anyone knows a way to do what that function does in Matlab but in Mathematica instead. $\endgroup$
    – EoDmnFOr3q
    Jan 18, 2018 at 14:20

1 Answer 1


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}

  • $\begingroup$ Perfect, thank you very much! $\endgroup$
    – EoDmnFOr3q
    Jan 17, 2018 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.