#include <CGAL/min_quadrilateral_2.h>
computes a minimum enclosing strip of the point set described by
[points_begin, points_end), writes its two bounding lines
to o and returns the past-the-end iterator of this sequence.
If the input range is empty or consists of one element only, o
remains unchanged.
Precondition
The points denoted by the range [points_begin, points_end) form the boundary of a simple convex polygon in counterclockwise orientation.The geometric types and operations to be used for the computation are specified by the traits class parameter t. The parameter can be omitted, if ForwardIterator refers to a two-dimensional point type from one the CGAL kernels. In this case, a default traits class (Min_quadrilateral_default_traits_2<K>) is used.
Requirement
File: examples/Min_quadrilateral_2/minimum_enclosing_strip_2.cpp
#include <CGAL/Cartesian.h> #include <CGAL/Polygon_2.h> #include <CGAL/point_generators_2.h> #include <CGAL/random_convex_set_2.h> #include <CGAL/min_quadrilateral_2.h> #include <iostream> struct Kernel : public CGAL::Cartesian<double> {}; typedef Kernel::Point_2 Point_2; typedef Kernel::Line_2 Line_2; typedef CGAL::Polygon_2<Kernel> Polygon_2; typedef CGAL::Random_points_in_square_2<Point_2> Generator; int main() { // build a random convex 20-gon p Polygon_2 p; CGAL::random_convex_set_2(20, std::back_inserter(p), Generator(1.0)); std::cout << p << std::endl; // compute the minimal enclosing strip p_m of p Line_2 p_m[2]; CGAL::min_strip_2(p.vertices_begin(), p.vertices_end(), p_m); std::cout << p_m[0] << "\n" << p_m[1] << std::endl; return 0; }