|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
A vertex in a polygon's doubly linked vertex list. More...
#include <polygon.H>
Public Member Functions | |
| Vertex ()=default | |
| Default constructor. Creates a vertex at origin (0, 0). | |
| Vertex (const Point &point) | |
| Construct a vertex from a Point. | |
| Vertex (const Vertex &vertex) | |
| Copy constructor. | |
| Vertex & | operator= (const Vertex &vertex) |
| Copy assignment operator. | |
| Point | to_point () const |
| Return this vertex as a plain Point value. | |
| const Vertex & | prev_vertex () const |
| Get the previous vertex in the polygon. | |
| const Vertex & | next_vertex () const |
| Get the next vertex in the polygon. | |
Public Member Functions inherited from Aleph::Point | |
| Point () | |
| Default constructor. | |
| Point (const Geom_Number &x, const Geom_Number &y) | |
| Constructs a point from Cartesian coordinates. | |
| Point (const Polar_Point &pp) | |
| Constructs a point from polar coordinates. | |
| bool | operator== (const Point &point) const noexcept |
| Checks for exact equality between two points. | |
| bool | operator!= (const Point &point) const noexcept |
| Checks for inequality between two points. | |
| bool | operator< (const Point &point) const noexcept |
| Defines a strict lexicographical ordering for points. | |
| Point | operator+ (const Point &p) const |
| Vector addition. | |
| Point & | operator+= (const Point &p) |
| Vector addition and assignment. | |
| Point | operator- (const Point &p) const |
| Vector subtraction. | |
| Point & | operator-= (const Point &p) |
| Vector subtraction and assignment. | |
| Point | operator- () const |
| Unary negation (vector inversion). | |
| Point | operator* (const Geom_Number &s) const |
| Scalar multiplication. | |
| Point | operator/ (const Geom_Number &s) const |
| Scalar division. | |
| Geom_Number | dot (const Point &p) const |
| Dot product. | |
| Geom_Number | cross (const Point &p) const |
| 2D cross-product (z-component of the 3D cross-product). | |
| Geom_Number | norm_squared () const |
| Squared Euclidean norm. | |
| Geom_Number | norm () const |
| Euclidean norm (vector magnitude). | |
| Point | normalize () const |
| Returns a normalized copy of this vector (magnitude 1). | |
| Point | rotate (const Geom_Number &angle) const |
| Rotates the point around the origin by a given angle. | |
| Point | lerp (const Point &other, const Geom_Number &t) const |
| Linear interpolation between this point and another. | |
| Point | midpoint (const Point &other) const |
| Calculates the midpoint between this point and another. | |
| const Geom_Number & | get_x () const noexcept |
| Gets the x-coordinate value. | |
| const Geom_Number & | get_y () const noexcept |
| Gets the y-coordinate value. | |
| bool | is_colinear_with (const Point &p1, const Point &p2) const |
| Checks if this point is collinear with two other points. | |
| bool | is_colinear_with (const Segment &s) const |
| Checks if this point is collinear with a segment. | |
| bool | is_left_of (const Point &p1, const Point &p2) const |
| Checks if this point is to the left of the directed line from p1 to p2. | |
| bool | is_to_left_from (const Point &p1, const Point &p2) const |
| bool | is_to_right_from (const Point &p1, const Point &p2) const |
| Checks if this point is to the right of the directed line from p1 to p2. | |
| bool | is_to_left_on_from (const Point &p1, const Point &p2) const |
| Checks if this point is to the left of or on the line from p1 to p2. | |
| bool | is_right_on_of (const Point &p1, const Point &p2) const |
| Checks if this point is to the right of or on the line from p1 to p2. | |
| bool | is_to_right_on_from (const Point &p1, const Point &p2) const |
| bool | is_clockwise_with (const Point &p1, const Point &p2) const |
| Determines if the sequence of three points (this, p1, p2) makes a clockwise turn. | |
| bool | is_left_of (const Segment &s) const |
| Checks if this point is to the left of a directed segment. | |
| bool | is_right_of (const Segment &s) const |
| Checks if this point is to the right of a directed segment. | |
| bool | is_to_left_from (const Segment &s) const |
| bool | is_to_right_from (const Segment &s) const |
| bool | is_clockwise_with (const Segment &s) const |
| Determines if the sequence (this, s.src, s.tgt) makes a clockwise turn. | |
| 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. | |
| const Point & | nearest_point (const Point &p1, const Point &p2) const |
| Returns which of the two points, p1 or p2, is nearer to this point. | |
| bool | is_inside (const Segment &s) const |
| Checks if this point is contained within a segment. | |
| bool | is_inside (const Ellipse &e) const |
| Checks if this point is contained within an ellipse. | |
| bool | intersects_with (const Ellipse &e) const |
| Checks if this point lies exactly on the boundary of an ellipse. | |
| std::string | to_string () const |
| Returns a string representation of the point as "(x,y)". | |
| operator std::string () const | |
Cast operator to std::string. | |
| Geom_Number | distance_squared_to (const Point &that) const |
| Calculates the squared Euclidean distance to another point. | |
| Geom_Number | distance_to (const Point &p) const |
| Calculates the Euclidean distance to another point. | |
| Geom_Number | distance_with (const Point &p) const |
| const Point & | highest_point () const |
| Returns the highest point (largest y-coordinate). | |
| const Point & | lowest_point () const |
| Returns the lowest point (smallest y-coordinate). | |
| const Point & | leftmost_point () const |
| Returns the leftmost point (smallest x-coordinate). | |
| const Point & | rightmost_point () const |
| Returns the rightmost point (largest x-coordinate). | |
Public Member Functions inherited from Aleph::Geom_Object | |
| Geom_Object ()=default | |
| virtual | ~Geom_Object ()=default |
Public Member Functions inherited from Aleph::Dlink | |
| template<typename T > | |
| Dnode< T > * | to_dnode () noexcept |
| template<typename T > | |
| const Dnode< T > * | to_dnode () const noexcept |
| template<typename T > | |
| T & | to_data () noexcept |
| template<typename T > | |
| const T & | to_data () const noexcept |
| Dlink () noexcept | |
| Initialize a node or an empty list. | |
| Dlink (const Dlink &l) noexcept | |
| Copy constructor. | |
| void | swap (Dlink *link) noexcept |
Swap this with list whose header is link. | |
| void | swap (Dlink &l) noexcept |
Swap this with list whose header is l. | |
| Dlink (Dlink &&l) noexcept | |
| Construct a new list with the items of l moved. | |
| Dlink & | operator= (const Dlink &l) noexcept |
| Copy assignation. | |
| Dlink & | operator= (Dlink &&l) noexcept |
| Move assignation. | |
| void | reset () noexcept |
Reset this | |
| void | init () noexcept |
| constexpr bool | is_empty () const noexcept |
Return true if this (as header node) is empty. | |
| constexpr bool | is_unitarian () const noexcept |
Return true if this (as header node) has exactly one element. | |
| constexpr bool | is_unitarian_or_empty () const noexcept |
Return true if this (as header node) has zero or one element. | |
| void | insert (Dlink *node) noexcept |
Insert node after this. | |
| void | push (Dlink *node) noexcept |
| void | append (Dlink *node) noexcept |
Insert node before this. | |
| Dlink *& | get_next () const noexcept |
Return the link that is after this | |
| Dlink *& | get_prev () const noexcept |
Return the link that is before this | |
| constexpr Dlink *& | get_first_ne () const noexcept |
If this is a header node, it return the first node of this | |
| constexpr Dlink *& | get_last_ne () const noexcept |
If this is a header node, it return the last node of this | |
| constexpr Dlink *& | get_first () const noexcept |
If this is a header node, it return the first node of this | |
| constexpr Dlink *& | get_last () const noexcept |
If this is a header node, it return the last node of this | |
| void | wrap_header (Dlink *l) noexcept |
| Wrap a header to a list (without header). | |
| void | insert_list (Dlink *head) noexcept |
Insert the list head before this | |
| void | append_list (Dlink *head) noexcept |
Insert the list head after this | |
| void | splice (Dlink *l) noexcept |
Insert a list l without header node after the node this. | |
| void | concat_list (Dlink *head) noexcept |
Concatenate list head to list this | |
| void | concat_list (Dlink &head) noexcept |
| Dlink * | del () noexcept |
Remove this from the list. this must not be a header node. | |
| void | erase () noexcept |
| Dlink * | remove_prev () noexcept |
Remove the item that is before this | |
| Dlink * | remove_next () noexcept |
Remove the item that is after this | |
| Dlink * | remove_last_ne () noexcept |
| Dlink * | remove_first_ne () noexcept |
| Dlink * | remove_last () noexcept |
| Dlink * | remove_first () noexcept |
| Dlink * | top () const |
| Dlink * | pop () |
| size_t | reverse_list () noexcept |
| Reverse the list. | |
| size_t | reverse () noexcept |
| size_t | split_list_ne (Dlink &l, Dlink &r) noexcept |
Split this in the middle in two lists. | |
| size_t | split_list (Dlink &l, Dlink &r) noexcept |
| Dlink | cut_list (Dlink *link) noexcept |
Cut this from link. | |
| void | remove_all_and_delete () noexcept |
| Remove and free memory for all the items of list. | |
| void | rotate_left (size_t n) |
| Rotate to left the list n positions. | |
| void | rotate_right (size_t n) |
| Analogous to rotate_left() but to right. | |
| bool | check () |
Return true if the list is consistent. | |
Static Public Member Functions | |
| static Vertex * | dlink_to_vertex (Dlink *link) |
| Convert a Dlink pointer to a Vertex pointer. | |
| static const Vertex * | dlink_to_vertex (const Dlink *link) |
| Convert a const Dlink pointer to a const Vertex pointer. | |
Additional Inherited Members | |
Protected Attributes inherited from Aleph::Dlink | |
| Dlink * | prev |
| Dlink * | next |
A vertex in a polygon's doubly linked vertex list.
The Vertex class combines a 2D point with doubly linked list capabilities. This allows polygons to store their vertices as an intrusive linked list while each vertex retains full Point functionality.
|
default |
Default constructor. Creates a vertex at origin (0, 0).
Convert a Dlink pointer to a Vertex pointer.
the link actually points to a Vertex. Definition at line 159 of file polygon.H.
Referenced by Aleph::Polygon::copy_points(), Aleph::Polygon::delete_points(), Aleph::Polygon::Iterator::get_curr(), Aleph::Polygon::Segment_Iterator::get_current_segment(), Aleph::Polygon::Vertex_Iterator::get_current_vertex(), Aleph::Polygon::get_first_vertex(), Aleph::Polygon::get_last_vertex(), Aleph::Polygon::get_next_vertex(), Aleph::Polygon::get_prev_vertex(), next_vertex(), prev_vertex(), TEST_F(), and TEST_F().
Get the next vertex in the polygon.
| std::domain_error | If this is the only vertex in the list. |
Definition at line 189 of file polygon.H.
References ah_domain_error_if, Aleph::divide_and_conquer_partition_dp(), dlink_to_vertex(), Aleph::Dlink::get_next(), Aleph::Dlink::is_empty(), and Aleph::Dlink::is_unitarian().
Referenced by Aleph::Polygon::Segment_Iterator::get_current_segment(), Aleph::Polygon::get_next_vertex(), and Aleph::CuttingEarsTriangulation::operator()().
Get the previous vertex in the polygon.
| std::domain_error | If this is the only vertex in the list. |
Definition at line 176 of file polygon.H.
References ah_domain_error_if, Aleph::divide_and_conquer_partition_dp(), dlink_to_vertex(), Aleph::Dlink::get_prev(), Aleph::Dlink::is_empty(), and Aleph::Dlink::is_unitarian().
Referenced by Aleph::Polygon::get_prev_vertex().
|
inline |
Return this vertex as a plain Point value.
Definition at line 150 of file polygon.H.
Referenced by Aleph::Polygon::add_vertex(), Aleph::CuttingEarsTriangulation::diagonal(), Aleph::Polygon::Segment_Iterator::get_current_segment(), Aleph::CuttingEarsTriangulation::operator()(), Aleph::Polygon::remove_vertex(), and TEST_F().