Is there a quick and efficient algorithm for calculating the volumetric center (probably the wrong term) of a polygon like that shown in the figure below somewhere around the blue dot? I'm not referring to centroid (approximately the red dot) as the average of points in the polygon, but based on the enclosed space. There won't be holes in this, though a solution which supports holes would also be welcome.

enter image description here

  • $\begingroup$ Find the center of mass of each of the three rectangles in your figure and then find the center of mass of those masses. This can be generalized to triangles. $\endgroup$ – The Count Aug 23 '18 at 15:10
  • 1
    $\begingroup$ I'm pretty sure the red dot in the figure is not the centroid. If you found it by averaging only the vertices of the polygon, that procedure only gives the centroid if the polygon is a triangle. $\endgroup$ – user856 Aug 23 '18 at 15:59
  • $\begingroup$ @Rahul I got the dots by ballparking where I thought they would end up between a volumetric and mean based average for the sake of the example, definitely not precise on either count. $\endgroup$ – CoryG Aug 23 '18 at 16:08
  • $\begingroup$ The Question asks for "a quick and efficient algorithm" for the centroid of a (two-dimensional) polygonal figure, so it is important to specify how the defining data of the polygon will be presented. So far an Answer is given which assumes an easy decomposition into rectangles. A more general solution can be given by triangulation and ear clipping, but I'd rather see an edit to the Question to describe how polygon data is provided. $\endgroup$ – hardmath Sep 24 '18 at 16:45
  • $\begingroup$ @hardmath An array of vertices seemed the only way to interpret it since that's how a polygon is always stored in a computer (with some minor adjustments for things like holes.) $\endgroup$ – CoryG Sep 25 '18 at 14:27

Pick your favorite origin and then the center of mass $\vec{v}_{cm}$ is:

$$\vec{v}_{cm} = \frac{\sum{A_j\vec{v}_j}}{\sum{A_j}}$$

where $A_j$ is the area of the $j$th rectangle and $\vec{v}_j$ is the center of the $j$th rectangle.

This assumes uniform density throughout the rectangles.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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