101# ifndef GEOM_ALGORITHMS_H
102# define GEOM_ALGORITHMS_H
188 if (
Segment curr = it.get_current_segment();
215 if (
a0.is_to_left_on_from(a, a1))
216 return a0.is_to_left_from(a, b)
and a1.is_to_left_from(b, a);
218 return not (a1.is_to_left_on_from(a, b)
and
219 a0.is_to_left_on_from(b, a));
248 Vertex & curr = it.get_current_vertex();
351 bool cmp_point(
const Point & p1,
const Point & p2)
const
353 if (p1.get_x() < p2.get_x())
356 return not (p2.get_x() < p1.get_x())
and p1.get_y() < p2.get_y();
374 for (
PointIt it(
l); it.has_curr(); it.next_ne())
376 const Point & p = it.get_curr();
378 if (p.is_to_right_from(s))
391 const Point &
p_i = i.get_curr();
395 const Point &
p_j = j.get_curr();
493 if (p.get_y() <
ret->get_y())
513 Point *
p_i = lowest_point;
514 ret.add_vertex(*lowest_point);
520 Point *
p_k =
nullptr;
522 double min_angle = std::numeric_limits<double>::max();
526 Point &
p_j = it.get_curr();
543 if (
p_k == lowest_point)
595 const Point & p = it.get_curr();
613 const Point & a,
const Point & b,
const Point & c)
621 if (p != a
and p != c
and p.is_to_right_from(a, c))
627 if (p != c
and p != b
and p.is_to_right_from(c, b))
663 if (p.get_x() < leftmost.get_x())
666 if (p.get_x() > rightmost.get_x())
670 return std::make_pair(leftmost, rightmost);
680 const Point & p = it.get_curr();
682 if (p.is_to_right_from(a, b))
716 ret.add_vertex(it.get_curr());
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Brute force convex hull algorithm.
DynList< Point >::Iterator PointIt
Polygon operator()(DynList< Point > &point_set)
Compute the convex hull of a point set.
bool are_all_points_on_left(DynList< Point > &l, const Segment &s)
SegmentSet extreme_edges(DynList< Point > &point_set)
Polygon triangulation using the ear-cutting algorithm.
static bool diagonalie(const Polygon &p, const Segment &s)
Check if a segment is a valid diagonal of the polygon.
static bool diagonal(const Polygon &p, const Vertex &a, const Vertex &b)
Check if segment (a, b) is a valid internal diagonal.
DynList< Triangle > operator()(Polygon &p)
Triangulate the polygon.
static EarsSet init_ears(const Polygon &p)
Initialize the set of ear vertices.
static bool in_cone(const Polygon &p, const Vertex &a, const Vertex &b)
Check if vertex b is inside the cone formed at vertex a.
Iterator on the items of list.
T & get_curr() const
Return the current item.
Dynamic singly linked list with functional programming support.
T & insert(const T &item)
Insert a new item by copy.
T & append(const T &item)
Append a new item by copy.
T remove()
Remove the first item of the list.
Dynamic set backed by balanced binary search trees with automatic memory management.
Gift wrapping (Jarvis march) convex hull algorithm.
Point * get_lowest_point(DynList< Point > &point_set)
Polygon operator()(DynList< Point > &point_set)
Compute the convex hull of a point set.
void next_ne() noexcept
Move the iterator one position forward guaranteeing no exception.
void next()
Move the iterator one item forward.
bool has_curr() const noexcept
Return true if iterator has current item.
constexpr bool is_empty() const noexcept
Return true if list is empty.
size_t size() const noexcept
Count the number of elements of the list.
void concat(HTList &l) noexcept
Concat to 'this' all 'l' list; 'l' becomes empty.
QuickHull convex hull algorithm.
std::pair< Point, Point > search_extremes(DynList< Point > &point_set)
Polygon operator()(DynList< Point > &point_set)
Compute the convex hull of a point set.
std::pair< DynList< Point >, DynList< Point > > get_right_points(DynList< Point > &point_set, const Point &a, const Point &b, const Point &c)
DynList< Point > quick_hull(DynList< Point > &point_set, const Point &a, const Point &b)
std::pair< DynList< Point >, DynList< Point > > partition(DynList< Point > &point_set, const Point &a, const Point &b)
Point get_fartest_point(DynList< Point > &point_set, const Segment &s)
Type * find_ptr(Operation &operation) noexcept(operation_is_noexcept< Operation >())
Find a pointer to an item in the container according to a searching criteria.
Iterator over the edges (segments) of a polygon.
bool has_curr() const
Check if there is a current segment.
A general (irregular) 2D polygon defined by a sequence of vertices.
void remove_vertex(const Vertex &v)
Remove a vertex from the polygon.
const Vertex & get_next_vertex(const Vertex &v) const
Get the vertex after the given vertex.
const size_t & size() const
Get the number of vertices.
const Vertex & get_first_vertex() const
Get the first vertex of the polygon.
const Vertex & get_prev_vertex(const Vertex &v) const
Get the vertex before the given vertex.
Fundamental segment defined by two points.
const Point & get_tgt_point() const
Segment get_perpendicular(const Point &p) const
Construct the segment perpendicular to this passing through p.
double counterclockwise_angle_with(const Segment &s) const
Compute the counterclockwise wise angle respect another segment s.
bool intersects_with(const Segment &s) const
Return true if s intersects this segment (including endpoints).
const Point & get_src_point() const
A vertex in a polygon's doubly-linked vertex list.
const Vertex & next_vertex() const
Get the next vertex in the polygon.
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
void next()
Advance all underlying iterators (bounds-checked).
DynList< T > maps(const C &c, Op op)
Classic map operation.
2D polygon representation and geometric operations.
bool operator()(const Segment &s1, const Segment &s2)
bool cmp_point(const Point &p1, const Point &p2) const
Iterator over the vertices of a polygon.
Dynamic set implementations based on balanced binary search trees.
Comprehensive sorting algorithms and search utilities for Aleph-w.