ivutils
|
A polygon is a two-dimensional shape that is created based on a set of 2D coordinates (contour).
Important members and methods of the class:
this->addPoint(Vector_2 point)
- adds a point to the polygonthis->GetCenter()
- returns the center of the polygonthis->GetCenter()
- returns the center of the polygonExample
VecContour<2> cnt; // create an empty set of points (empty contour) cnt.add(Vector_2(0,0)); cnt.add(Vector_2(0,1)); // Add 4 2D coordinates {0,0}, {0,1}, {1,0}, {1,1} cnt.add(Vector_2(1,0)); cnt.add(Vector_2(1,1)); Polygon_2 poly(&cnt); // Creating a polygon based on it cnt = *( poly->get_contour() );// We get back from the polygon a set of 2D coordinates (contour)