2d convex hull in pierre alliez
TRANSCRIPT
![Page 1: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/1.jpg)
2D Convex Hull in2D Convex Hull in
http://www.cgal.orghttp://www.cgal.org
Pierre AlliezPierre Alliez
![Page 2: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/2.jpg)
http://http://www.cgal.orgwww.cgal.org
OutlineOutline
• DefinitionsDefinitions• Convex hull in CGALConvex hull in CGAL
– InterfaceInterface– Extreme pointsExtreme points– Subsequences of hull pointsSubsequences of hull points– Convexity CheckingConvexity Checking
• ExerciseExercise
![Page 3: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/3.jpg)
http://http://www.cgal.orgwww.cgal.org
DefinitionsDefinitions
• A subset A subset S S IRIR22 is is convexconvex if for any if for any two points two points p p and and q q in the set the in the set the line segment with endpoints line segment with endpoints p p and and q q is contained in is contained in SS. .
• The The convex hullconvex hull of a set of a set S S is the is the smallest convex set containing smallest convex set containing SS. .
• The The convex hull of a set of points convex hull of a set of points PP is a convex polygon with vertices in is a convex polygon with vertices in PP. .
![Page 4: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/4.jpg)
http://http://www.cgal.orgwww.cgal.org
DefinitionsDefinitions
• A point in A point in P P is an is an extremeextreme point (with point (with respect to respect to PP) if it is a vertex of the ) if it is a vertex of the convex hull of convex hull of PP. .
• A point set is said to be A point set is said to be strongly convexstrongly convex if it consists of only extreme points.if it consists of only extreme points.
![Page 5: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/5.jpg)
http://http://www.cgal.orgwww.cgal.org
Convex Hull in CGALConvex Hull in CGAL
5 algorithms to compute the 5 algorithms to compute the counterclockwisecounterclockwise sequence of sequence of extreme pointsextreme points for a 2D point for a 2D point set.set. 11
22
33 44
55
66
![Page 6: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/6.jpg)
http://http://www.cgal.orgwww.cgal.org
Convex Hull in CGALConvex Hull in CGAL
nn input points with input points with hh extreme points extreme points
Algorithms:Algorithms:• [Bykat 78][Bykat 78] O( O(nhnh) output-sensitive) output-sensitive• [Akl & Toussaint][Akl & Toussaint] O( O(nlognnlogn) worst ) worst
casecase• [Graham-Andrew][Graham-Andrew] O( O(nlognnlogn))• [Jarvis 73][Jarvis 73] O( O(nhnh))• [Eddy][Eddy] O( O(nhnh))
![Page 7: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/7.jpg)
http://http://www.cgal.orgwww.cgal.org
InterfaceInterface
template <class InputIterator, class OutputIterator>template <class InputIterator, class OutputIterator>
OutputIterator OutputIterator convex_hull_2convex_hull_2(InputIterator first,(InputIterator first, InputIterator beyond, InputIterator beyond, OutputIterator result, OutputIterator result, Traits ch_traits = Traits ch_traits = Default_traits) Default_traits)
generates the counterclockwise sequence of extreme points of the points in the range [first,beyond). The resulting sequence is placed starting at position result, and the past-the-end iterator for the resulting sequence is returned (it is not specified at which point the cyclic sequence of extreme points is cut into a linear sequence).
![Page 8: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/8.jpg)
http://http://www.cgal.orgwww.cgal.org
InterfaceInterface
template <class InputIterator, class OutputIterator>
OutputIterator convex_hull_2(InputIterator first, InputIterator beyond, OutputIterator result, Traits ch_traits = Default_traits)
InputIterator::value_type
OutputIterator::value_type
Traits contains types and functions:
Traits::Point_2, Traits::Less_xy_2, Traits::Less_yx_2, Traits::Leftturn_2.
Traits::Point_2Traits::Point_2
![Page 9: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/9.jpg)
http://http://www.cgal.orgwww.cgal.org
Default...Default...#include#include <CGAL/Cartesian.h> <CGAL/Cartesian.h>
#include#include <CGAL/convex_hull_2.h> <CGAL/convex_hull_2.h>
#include#include < <listlist>>
typedeftypedef CGAL::Cartesian< CGAL::Cartesian<doubledouble> > kernelkernel;;
typedeftypedef kernelkernel::Point_2 ::Point_2 PointPoint;;
std::liststd::list<<PointPoint> points;> points;
std::liststd::list<<PointPoint> hull;> hull;
points.push_back(points.push_back(PointPoint(0,0)); (0,0));
points.push_back(points.push_back(PointPoint(0,1));(0,1));
// ...// ...
CGAL::convex_hull_2CGAL::convex_hull_2(points.begin(),(points.begin(),
points.end(),points.end(),
std::inserterstd::inserter(hull,hull.begin()));(hull,hull.begin()));
![Page 10: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/10.jpg)
http://http://www.cgal.orgwww.cgal.org
Graham-AndrewGraham-Andrew#include#include <CGAL/Cartesian.h> <CGAL/Cartesian.h>
#include#include <CGAL/graham_andrew.h> <CGAL/graham_andrew.h>
#include#include < <listlist>>
typedeftypedef CGAL::Cartesian< CGAL::Cartesian<doubledouble> > kernelkernel;;
typedeftypedef kernelkernel::Point_2 ::Point_2 PointPoint;;
std::liststd::list<<PointPoint> points;> points;
std::liststd::list<<PointPoint> hull;> hull;
points.push_back(points.push_back(PointPoint(0,0)); (0,0));
points.push_back(points.push_back(PointPoint(0,1));(0,1));
// ...// ...
CGAL::ch_graham_andrewCGAL::ch_graham_andrew(points.begin(),(points.begin(),
points.end(),points.end(),
std::inserterstd::inserter(hull,hull.begin()));(hull,hull.begin()));
![Page 11: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/11.jpg)
http://http://www.cgal.orgwww.cgal.org
Extreme PointsExtreme Points
• North, South, East, West and North, South, East, West and combinations.combinations.
NN
WW
SS
EE
![Page 12: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/12.jpg)
http://http://www.cgal.orgwww.cgal.org
SubSequences of Hull SubSequences of Hull PointsPoints
• Lower HullLower Hull• Upper HullUpper Hull
22
11
22 33
44
11
![Page 13: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/13.jpg)
http://http://www.cgal.orgwww.cgal.org
Convexity CheckingConvexity Checking
#include <CGAL/convexity_check_2.h>
template <class ForwardIterator, class Traits>
bool is_ccw_strongly_convex_2 (
ForwardIterator first,
ForwardIterator beyond,
Traits ch_traits = Default_traits)
returns true iff the point elements in [first,beyond) form a counterclockwise-oriented strongly convex polygon.
![Page 14: 2D Convex Hull in Pierre Alliez](https://reader036.vdocuments.net/reader036/viewer/2022082713/5697bff81a28abf838cbf76c/html5/thumbnails/14.jpg)
http://http://www.cgal.orgwww.cgal.org
ExerciseExercise