ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ConvexHull.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*--------------------------- File ConvexHull.h ----------------------------*/
3/*--------------------------------------------------------------------------*/
70/*--------------------------------------------------------------------------*/
71/*----------------------------- DEFINITIONS --------------------------------*/
72/*--------------------------------------------------------------------------*/
73
74#ifndef __ADS_ConvexHull
75 #define __ADS_ConvexHull
76/* self-identification: #endif constant */
77
78/*--------------------------------------------------------------------------*/
79/*------------------------------ INCLUDES ----------------------------------*/
80/*--------------------------------------------------------------------------*/
81
82#include "ADS/Contract.h"
83#include "ADS/sort/Sort.h"
84
85#include <algorithm>
86#include <cmath>
87#include <cstddef>
88#include <cstdint>
89#include <cstdlib>
90#include <vector>
91
92/*--------------------------------------------------------------------------*/
93/*--------------------------- NAMESPACE ------------------------------------*/
94/*--------------------------------------------------------------------------*/
95
96namespace ADS
97{
98
100struct Point
101{
102 long x ,
105 bool operator==( const Point & ) const = default;
106 };
107
117inline long long cross( const Point & a , const Point & b , const Point & c );
118
133inline bool sameSide( const Point & p1 , const Point & p2 , const Point & p ,
134 const Point & q );
135
154inline double pseudoAngle( long dx , long dy );
155
181inline std::vector< Point > convexHullBrute( std::vector< Point > P );
182
213inline std::vector< Point > graham( std::vector< Point > P );
214
245inline std::vector< Point > convexHull( const std::vector< Point > & P );
246
247/*--------------------------------------------------------------------------*/
248
249} // end( namespace ADS )
250
251/*--------------------------------------------------------------------------*/
252/*-------------------------- IMPLEMENTATION --------------------------------*/
253/*--------------------------------------------------------------------------*/
254
255#include "ADS/geometry/impl/ConvexHull.tpp"
256
257/*--------------------------------------------------------------------------*/
258
259#endif /* ConvexHull.h included */
260
261/*--------------------------------------------------------------------------*/
262/*------------------------- End File ConvexHull.h --------------------------*/
263/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The sort that chooses its algorithm, beyond the book: sort() and stableSort() look at what they sort ...
bool sameSide(const Point &p1, const Point &p2, const Point &p, const Point &q)
true if and are on the same side of the line through and , or on it (the stessaparte() of the book...
long long cross(const Point &a, const Point &b, const Point &c)
the cross product : positive if is to the left of the line from to , 0 if on it; in long long,...
double pseudoAngle(long dx, long dy)
an increasing function of the angle of the vector , in and with no arctangent (exercise 16....
std::vector< Point > graham(std::vector< Point > P)
the vertices of the hull in counterclockwise order from the lowest point, the rightmost of the lowest...
std::vector< Point > convexHullBrute(std::vector< Point > P)
the hull by checking every segment, ; the vertices in counterclockwise order from the lowest one
std::vector< Point > convexHull(const std::vector< Point > &P)
the hull by the octagon of Akl and Toussaint, the radix sort and the monotone chain of Andrew; the ve...
Definition ADT.h:96
a point of the plane, of integer coordinates
Definition ConvexHull.h:101
long y
the ordinate
Definition ConvexHull.h:103
bool operator==(const Point &) const =default
true if the two points have the same coordinates
long x
the abscissa
Definition ConvexHull.h:102