Replies: 2 comments 1 reply
-
Hi, The function CGAL::centroid takes as a last input the dimension of the input, i.e., CGAL::Dimension_tag<0>(). In your case, you provide the function iterators of points and the dimension 0. If instead you provide triangles and CGAL::Dimension_tag<2>(), you will get the centroid of the 2d polygon. There is also the centroid example in the Principal component analysis package, that shows the difference. |
Beta Was this translation helpful? Give feedback.
-
@MaelRL @palliez when computing the area of a polygon on adds the signed areas of triangles formed by the origin and two consecutive polygon vertices. Can something similar be done for the centroid of a polygon, that is without triangulating the polygon explicitly? |
Beta Was this translation helpful? Give feedback.
-
I'm using CGAL 5.5 and I tried to compute centroid for a simple 2D polygon. When using the formula for composite shapes the resulting centroid is (2.63, 1.7) as shown below. [Source]
But when I'm using CGAL::centroid, the centroid returns (2.5, 1.5). What could be causing this discrepancy?
Beta Was this translation helpful? Give feedback.
All reactions