|
ADS
Algorithms and Data Structures
|
The convex hull of a set \( P \) of \( n \) points of the plane (section 16.1), the smallest convex polygon that contains them, as its vertices in counterclockwise order. More...
#include "ADS/Contract.h"#include "ADS/sort/Sort.h"#include <algorithm>#include <cmath>#include <cstddef>#include <cstdint>#include <cstdlib>#include <vector>#include "ADS/geometry/impl/ConvexHull.tpp"Go to the source code of this file.
Classes | |
| struct | ADS::Point |
| a point of the plane, of integer coordinates More... | |
Namespaces | |
| namespace | ADS |
Functions | |
| long long | ADS::cross (const Point &a, const Point &b, const Point &c) |
| the cross product \( ( b - a ) \times ( c - a ) \): positive if \( c \) is to the left of the line from \( a \) to \( b \), 0 if on it; in long long, as long may have 32 bits | |
| bool | ADS::sameSide (const Point &p1, const Point &p2, const Point &p, const Point &q) |
| true if \( p \) and \( q \) are on the same side of the line through \( p_1 \) and \( p_2 \), or on it (the stessaparte() of the book) | |
| double | ADS::pseudoAngle (long dx, long dy) |
| an increasing function of the angle of the vector \( ( \mathit{dx} , \mathit{dy} ) \), in \( [ 0 , 4 ) \) and with no arctangent (exercise 16.1) | |
| std::vector< Point > | ADS::convexHullBrute (std::vector< Point > P) |
| the hull by checking every segment, \( O( n^3 ) \); the vertices in counterclockwise order from the lowest one | |
| std::vector< Point > | ADS::graham (std::vector< Point > P) |
| the vertices of the hull in counterclockwise order from the lowest point, the rightmost of the lowest ones, by the scan of Graham | |
| std::vector< Point > | ADS::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 vertices as graham() gives them | |
The convex hull of a set \( P \) of \( n \) points of the plane (section 16.1), the smallest convex polygon that contains them, as its vertices in counterclockwise order.
The side of a point \( q \) with respect to the line through \( p_1 \) and \( p_2 \) is the sign of the cross product \( ( x_2 - x_1 ) ( y_q - y_1 ) - ( y_2 - y_1 ) ( x_q - x_1 ) \), and sameSide(), the stessaparte() of the book, is the product of two such signs not being negative; with integer coordinates it is exact.
The contracts [see Contract.h]: the pseudo-angle is in \( [ 0 , 4 ) \), and the hulls are convex, counterclockwise, made of input points and contain all of them (checked at level 3). The operations are defined in ConvexHull.tpp.