ivutils
Loading...
Searching...
No Matches
Polygon (Polygon_2)

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 polygon
  • this->GetCenter() - returns the center of the polygon
  • this->GetCenter() - returns the center of the polygon

Example

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)