Message Boards Message Boards

GROUPS:

Avoid issues using RegionCentroid on Polygon?

Posted 1 month ago
236 Views
|
3 Replies
|
4 Total Likes
|

So I'm having an issue where the RegionCentroid operation does not compute even though I've used it successfully many times in the past.

Here are the coordinates of the shape I'm trying to determine the centroid for:

C1 = {-0.82998570, 0.39131282, 1.38566726}
C2 = {-0.01947705, -0.00824240, 2.45464906}
C3 = {1.21666293, -0.61144232, 2.04941022}
C4 = {1.35625427, -0.67525738, 0.64442667}
S = {-0.01598580, -0.00235848, -0.00262605}

Here I'm building the Polygon:

Plane= Polygon[{C1, C2, C3, C4, S}]

And here is what what I'm using to determine the centroid of the region:

OO=RegionCentroid[Plane]

This is an issue I'm experiencing in Mathematica 11.3. That exact line of commands worked fine in Mathematica 10. I'm getting the error message shown below. enter image description here

Any ideas as to why this is happening and how to fix it?

Thanks!

3 Replies

Hi Victor,

your 5 points do seem to be located on a plane, but maybe not in a "perfect" way (there is a tiny deviation), so my guess is that this is the problem. A solution could be to regard your polygon as a 3D object and do it like so:

RegionCentroid[ConvexHullMesh[{C1, C2, C3, C4, S}]]
(* Out: *)   {0.4082527412619907`, -0.21401562097540627`, 1.3631274362901387`}

Regards -- Henrik

The current behavior is that for points in 3D space:

Polygon[{C1, C2, C3, C4}] // RegionQ (*False*)
Polygon[{C1, C2, C3}] // RegionQ (*True*)

Because Polygon with 4 3-d points is not guaranteed to be one plane. Even all $C_k$ points are mathematically co-planar, Plane in your case is treated always a 3-D object.

To find the centroid of the polygon bounded by these points, Use the built-in mesh function to generate the 3-d region:

Plane = ConvexHullMesh[{C2, C1, C3, C4, S}]
(* Plane = DelaunayMesh[{C1, C2, C3, C4, S}] also ok*)

Or use BoundaryMeshRegion. Then check with

RegionDimension[Plane] (* = 3 *)
OO = RegionCentroid[Plane] (* = {0.408253,-0.214016,1.36313} *)
Posted 1 month ago

Got it! Thank you very much for both suggestions! They worked perfectly.

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