CGAL 6.1.2 - 2D Minkowski Sums: Minkowski_sum_2/sum_triangle_square.cpp

CGAL 6.1.2 - 2D Minkowski Sums

Loading...
Searching...
No Matches
Minkowski_sum_2/sum_triangle_square.cpp
// Computing the Minkowski sum of a triangle and a square.
#include <CGAL/minkowski_sum_2.h>
#include "bops_linear.h"
int main()
{
// Construct the triangle.
Polygon_2 P;
P.push_back(Point_2(-1, -1)); P.push_back(Point_2(1, -1));
P.push_back(Point_2(0, 1));
std::cout << "P = " << P << std::endl;
// Construct the square.
Polygon_2 Q;
Q.push_back(Point_2(3, -1)); Q.push_back(Point_2(5, -1));
Q.push_back(Point_2(5, 1)); Q.push_back(Point_2(3, 1));
std::cout << "Q = " << Q << std::endl;
// Compute the Minkowski sum.
Polygon_with_holes_2 sum = CGAL::minkowski_sum_2(P, Q);
assert(sum.number_of_holes() == 0);
std::cout << "P (+) Q = " << sum.outer_boundary() << std::endl;
return 0;
}
CGAL::minkowski_sum_2
Polygon_with_holes_2< Kernel, Container > minkowski_sum_2(const PolygonType1< Kernel, Container > &P, const PolygonType2< Kernel, Container > &Q)
Computes the Minkowski sum of two given polygons (which may have holes).