Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
point_utils.H
Go to the documentation of this file.
1
2/*
3 Aleph_w
4
5 Data structures & Algorithms
6 version 2.0.0b
7 https://github.com/lrleon/Aleph-w
8
9 This file is part of Aleph-w library
10
11 Copyright (c) 2002-2026 Leandro Rabindranath Leon
12
13 Permission is hereby granted, free of charge, to any person obtaining a copy
14 of this software and associated documentation files (the "Software"), to deal
15 in the Software without restriction, including without limitation the rights
16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 copies of the Software, and to permit persons to whom the Software is
18 furnished to do so, subject to the following conditions:
19
20 The above copyright notice and this permission notice shall be included in all
21 copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 SOFTWARE.
30*/
31
32
45# ifndef POINT_UTILS_H
46# define POINT_UTILS_H
47
48# include <point.H>
49
50namespace Aleph
51{
52
53[[deprecated("Use area_of_triangle() from point.H")]]
55 const Point & b,
56 const Point & c)
57{
58 return area_of_triangle(a, b, c);
59}
60
61[[deprecated("Use points_are_colinear via Point::is_colinear_with()")]]
62inline bool points_are_colinear(const Point & a,
63 const Point & b,
64 const Point & c)
65{
66 return area_of_parallelogram(a, b, c) == 0;
67}
68
69[[deprecated("Use orientation() from point.H")]]
70inline bool c_is_to_left_(const Point & a, const Point & b, const Point & c)
71{
72 return area_of_parallelogram(a, b, c) > 0;
73}
74
75[[deprecated("Use orientation() from point.H")]]
76inline bool is_clockwise(const Point & a, const Point & b, const Point & c)
77{
78 return area_of_parallelogram(a, b, c) < 0;
79}
80
81[[deprecated("Use orientation() from point.H")]]
82inline bool left_on(const Point & a, const Point & b, const Point & c)
83{
84 return area_of_parallelogram(a, b, c) >= 0;
85}
86
87[[deprecated("Use Segment::intersects_properly_with() from point.H")]]
88inline bool proper_intersection(const Point & a, const Point & b,
89 const Point & c, const Point & d)
90{
91 const Orientation abc = orientation(a, b, c);
92 const Orientation abd = orientation(a, b, d);
93 const Orientation cda = orientation(c, d, a);
94 const Orientation cdb = orientation(c, d, b);
97 return false;
98
99 return abc != abd and cda != cdb;
100}
101
102[[deprecated("Use Point::is_between() from point.H")]]
103inline bool between(const Point & a, const Point & b, const Point & c)
104{
105 return c.is_between(a, b);
106}
107
108[[deprecated("Use Segment::intersects_with() from point.H")]]
109inline bool intersect_improp(const Point & a, const Point & b,
110 const Point & c, const Point & d)
111{
112 return c.is_between(a, b) or d.is_between(a, b) or
113 a.is_between(c, d) or b.is_between(c, d);
114}
115
116[[deprecated("Use segments_intersect() from point.H")]]
117inline bool intersectp(const Point & a, const Point & b,
118 const Point & c, const Point & d)
119{
120 return segments_intersect(a, b, c, d);
121}
122
123} // namespace Aleph
124
125// Preserve source compatibility for legacy unqualified calls while keeping
126// every implementation in the library namespace.
128using Aleph::between;
133using Aleph::left_on;
136
137
138# endif // POINT_UTILS_H
Represents a point with rectangular coordinates in a 2D plane.
Definition point.H:221
bool is_between(const Point &p1, const Point &p2) const
Checks if this point is on the bounding box of p1 and p2 and is collinear with them.
Definition point.H:588
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
Geom_Number area_of_triangle_legacy(const Point &a, const Point &b, const Point &c)
Definition point_utils.H:54
Orientation
Classification of three-point orientation.
Definition point.H:2894
Geom_Number area_of_parallelogram(const Point &a, const Point &b, const Point &c)
Compute the signed area of the parallelogram defined by vectors a->b and a->c.
Definition point.H:2886
bool points_are_colinear(const Point &a, const Point &b, const Point &c)
Definition point_utils.H:62
bool is_clockwise(const Point &a, const Point &b, const Point &c)
Definition point_utils.H:76
bool segments_intersect(const Segment &s1, const Segment &s2)
Return true if segments s1 and s2 intersect (including endpoints).
Definition point.H:2967
and
Check uniqueness with explicit hash + equality functors.
Geom_Number area_of_triangle(const Point &a, const Point &b, const Point &c)
Return the (unsigned) area of triangle (a, b, c) as an exact rational.
Definition point.H:3037
bool left_on(const Point &a, const Point &b, const Point &c)
Definition point_utils.H:82
Orientation orientation(const Point &a, const Point &b, const Point &c)
Return the orientation of the triple (a, b, c).
Definition point.H:2902
bool c_is_to_left_(const Point &a, const Point &b, const Point &c)
Definition point_utils.H:70
bool intersectp(const Point &a, const Point &b, const Point &c, const Point &d)
bool intersect_improp(const Point &a, const Point &b, const Point &c, const Point &d)
bool between(const Point &a, const Point &b, const Point &c)
bool proper_intersection(const Point &a, const Point &b, const Point &c, const Point &d)
Definition point_utils.H:88
2D point and geometric utilities.