Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Vertex Class Reference

A vertex in a polygon's doubly linked vertex list. More...

#include <polygon.H>

Inheritance diagram for Aleph::Vertex:
[legend]
Collaboration diagram for Aleph::Vertex:
[legend]

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.
 
Vertexoperator= (const Vertex &vertex)
 Copy assignment operator.
 
Point to_point () const
 Return this vertex as a plain Point value.
 
const Vertexprev_vertex () const
 Get the previous vertex in the polygon.
 
const Vertexnext_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.
 
Pointoperator+= (const Point &p)
 Vector addition and assignment.
 
Point operator- (const Point &p) const
 Vector subtraction.
 
Pointoperator-= (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_Numberget_x () const noexcept
 Gets the x-coordinate value.
 
const Geom_Numberget_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 Pointnearest_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 Pointhighest_point () const
 Returns the highest point (largest y-coordinate).
 
const Pointlowest_point () const
 Returns the lowest point (smallest y-coordinate).
 
const Pointleftmost_point () const
 Returns the leftmost point (smallest x-coordinate).
 
const Pointrightmost_point () const
 Returns the rightmost point (largest x-coordinate).
 
- Public Member Functions inherited from Aleph::Geom_Object
 Geom_Object ()=default
 
virtual ~Geom_Object ()=default
 

Static Public Member Functions

static Vertexdlink_to_vertex (Dlink *link)
 Convert a Dlink pointer to a Vertex pointer.
 
static const Vertexdlink_to_vertex (const Dlink *link)
 Convert a const Dlink pointer to a const Vertex pointer.
 

Additional Inherited Members

Detailed Description

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.

Design

  • Inherits from Point for geometric coordinates.
  • Inherits from Dlink for doubly linked list traversal.
  • Provides navigation to adjacent vertices in the polygon.
Note
Vertex objects are typically managed by a Polygon and should not be manually linked/unlinked outside Polygon's methods.
See also
Polygon

Definition at line 118 of file polygon.H.

Constructor & Destructor Documentation

◆ Vertex() [1/3]

Aleph::Vertex::Vertex ( )
default

Default constructor. Creates a vertex at origin (0, 0).

◆ Vertex() [2/3]

Aleph::Vertex::Vertex ( const Point point)
inline

Construct a vertex from a Point.

Parameters
pointThe point to copy coordinates from.

Definition at line 126 of file polygon.H.

◆ Vertex() [3/3]

Aleph::Vertex::Vertex ( const Vertex vertex)
inline

Copy constructor.

Parameters
vertexThe vertex to copy.
Note
Only copies the Point coordinates; does not copy the link state.

Definition at line 133 of file polygon.H.

Member Function Documentation

◆ dlink_to_vertex() [1/2]

static const Vertex * Aleph::Vertex::dlink_to_vertex ( const Dlink link)
inlinestatic

Convert a const Dlink pointer to a const Vertex pointer.

Parameters
linkPointer to a const Dlink that is actually a Vertex.
Returns
Pointer to the const Vertex.

Definition at line 167 of file polygon.H.

◆ dlink_to_vertex() [2/2]

static Vertex * Aleph::Vertex::dlink_to_vertex ( Dlink link)
inlinestatic

◆ next_vertex()

const Vertex & Aleph::Vertex::next_vertex ( ) const
inline

Get the next vertex in the polygon.

Returns
Reference to the next vertex.
Exceptions
std::domain_errorIf this is the only vertex in the list.
Precondition
The vertex must be part of a polygon with at least 2 vertices.

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()().

◆ operator=()

Vertex & Aleph::Vertex::operator= ( const Vertex vertex)
inline

Copy assignment operator.

Parameters
vertexThe vertex to copy.
Returns
Reference to this vertex.
Note
Only copies Point coordinates; does not modify the link state.

Definition at line 141 of file polygon.H.

◆ prev_vertex()

const Vertex & Aleph::Vertex::prev_vertex ( ) const
inline

Get the previous vertex in the polygon.

Returns
Reference to the previous vertex.
Exceptions
std::domain_errorIf this is the only vertex in the list.
Precondition
The vertex must be part of a polygon with at least 2 vertices.

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().

◆ to_point()

Point Aleph::Vertex::to_point ( ) const
inline

The documentation for this class was generated from the following file: