Difference in behavior between RegionNearest for a polygon's centroid in 2D

Difference in behavior between RegionNearest for a polygon’s centroid in 2D vs 3D

Consider a simple 2-d polygon whose centroid is outside of the polygon:

Here is the polygon:

region = Polygon[{{0, 0}, {1, 1}, {2, 0}, {1, 3/4}}];
Graphics[region, Axes -> True]

giving

Now plot the centroid along with the point in the region closest to the centroid (yes there are technically two that are closest =because of teh symmetry, but RegionNearest chooses one–that’s fine):

Graphics[{AbsolutePointSize[10], LightBlue, region, Red, 
  Point[RegionCentroid[region]], Darker@Green, 
  Point[RegionNearest[region, RegionCentroid[region]]]}, 
 ImageSize -> 400]

giving (red point for the centroid and green point for the nearest in the region):

Now let’s do this in 3D:

region3d = Polygon[{{0, 0, 0}, {1, 1, 0}, {2, 0, 0}, {1, 3/4, 0}}];
Graphics3D[region3d, Axes -> True]

giving

and

Graphics3D[{AbsolutePointSize[10], LightBlue, region3d, Red, 
  Point[RegionCentroid[region3d]], Darker@Green, 
  Point[RegionNearest[region3d, RegionCentroid[region3d]]]}, 
 ImageSize -> 400]

giving

So the obvious question here is why the nearest point to the centroid is now at the centroid.

For some (approximate) idea of what is going wrong in the 3D case, take a look at

 Map[DiscretizeGraphics, {region, region3d}]

So would this be considered a bug primarily in DiscretizeGraphics? I assume that the RegionCentroid and the RegionNearest are being computed by making use of the triangulations shown in DiscretizeGraphics.

Also , strangely, if I close the polygon explicitly as in this

Polygon[{{0, 0, 0}, {1, 1, 0}, {2, 0, 0}, {1, 3/4, 0}, {0, 0, 0}}] 

then

RegionCentroid[
 Polygon[{{0, 0, 0}, {1, 1, 0}, {2, 0, 0}, {1, 3/4, 0}, {0, 0, 0}}]] 

fails with the error message

RegionCentroid::nmet: Unable to compute the centroid of region
Polygon[{{0,0,0},{1,1,0},{2,0,0},{1,3/4,0},{0,0,0}}]. >>

So would this be considered a bug primarily in DiscretizeGraphics?

Not exactly, it was only an illustration. The problem happens in an internal polygon triangulation routine.

The polygon is already closed, so repeating the vertex will just introduce a degeneracy, which is not supported. The 2D case would also fail.