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

Represents a line segment between two points. More...

#include <point.H>

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

Public Types

enum  Sense {
  E , NE , N , NW ,
  W , SW , S , SE
}
 Cardinal and intercardinal directions associated with a segment's vector. More...
 

Public Member Functions

bool operator== (const Segment &s) const noexcept
 Checks for equality between two segments.
 
bool operator!= (const Segment &s) const noexcept
 Checks for inequality between two segments.
 
const Pointhighest_point () const noexcept
 Gets the endpoint with the largest y-coordinate.
 
const Pointlowest_point () const noexcept
 Gets the endpoint with the smallest y-coordinate.
 
const Pointleftmost_point () const noexcept
 Gets the endpoint with the smallest x-coordinate.
 
const Pointrightmost_point () const noexcept
 Gets the endpoint with the largest x-coordinate.
 
const Pointget_src_point () const noexcept
 Gets the source point of the segment.
 
const Pointget_tgt_point () const noexcept
 Gets the target point of the segment.
 
 Segment ()=default
 Default constructor.
 
 Segment (Point src, Point tgt)
 Constructs a segment from two endpoints.
 
 Segment (Point src, const Geom_Number &m, const Geom_Number &l)
 Constructs a new segment from a source point, slope, and length.
 
 Segment (const Segment &sg, const Geom_Number &dist)
 Constructs a new segment parallel to a given segment at a specified distance.
 
double slope () const
 Returns the slope of the segment.
 
Geom_Number slope_exact () const
 Returns the exact slope of the segment as a Geom_Number.
 
double counterclockwise_angle_with (const Segment &s) const
 Computes the counter-clockwise rotation angle FROM this segment TO another.
 
double counterclockwise_angle () const
 Computes the counter-clockwise angle of this segment with respect to the x-axis.
 
Geom_Number length () const
 Returns the Euclidean length of the segment.
 
Geom_Number size () const
 
bool is_colinear_with (const Point &p) const
 Checks if a point is collinear with this segment.
 
bool is_left_of (const Point &p) const
 Checks if this segment is to the left of a given point.
 
bool is_right_of (const Point &p) const
 Checks if this segment is to the right of a given point.
 
bool is_to_left_from (const Point &p) const
 
bool is_to_right_from (const Point &p) const
 
Point mid_point () const
 Returns the midpoint of this segment.
 
Segment reversed () const
 Returns a new segment with the endpoints swapped.
 
Point at (const Geom_Number &t) const
 Evaluates a point on the segment via linear interpolation.
 
Point project (const Point &p) const
 Orthogonal projection of a point onto this segment's infinite line, clamped to the segment's endpoints.
 
Geom_Number distance_to (const Point &p) const
 Calculates the Euclidean distance from a point to this segment.
 
const Pointnearest_point (const Point &p) const
 Returns whichever endpoint of this segment is nearer to a given point.
 
Segment get_perpendicular (const Point &p) const
 Constructs a segment perpendicular to this that passes through point p.
 
Segment mid_perpendicular (const Geom_Number &dist) const
 Returns the perpendicular chord of a given length passing through the midpoint.
 
bool intersects_properly_with (const Segment &s) const
 Checks if this segment properly intersects another segment.
 
bool contains (const Point &p) const
 Checks if a point lies on this segment.
 
bool contains_to (const Point &p) const
 
bool contains (const Segment &s) const
 Checks if another segment s lies entirely inside this segment.
 
bool contains_to (const Segment &s) const
 
bool intersects_with (const Segment &s) const
 Checks if this segment intersects another one (including endpoints and collinear overlap).
 
bool intersects_with (const Triangle &t) const
 Checks if this segment intersects a triangle.
 
bool intersects_with (const Ellipse &e) const
 Checks if this segment intersects an ellipse.
 
bool is_parallel_with (const Segment &s) const
 Checks if this segment is parallel to another one.
 
Point intersection_with (const Segment &s) const
 Computes the intersection point of the infinite lines defined by two segments.
 
Sense sense () const
 Determines the cardinal/intercardinal direction of the segment.
 
void enlarge_src (const Geom_Number &dist)
 Extends the segment by a given distance from the source endpoint.
 
void enlarge_tgt (const Geom_Number &dist)
 Extends the segment by a given distance from the target endpoint.
 
std::string to_string () const
 Returns a string representation of the segment, e.g., "(x1,y1)(x2,y2)".
 
 operator std::string () const
 Cast operator to std::string.
 
void rotate (const Geom_Number &angle)
 Rotates the segment by a given angle around its source point.
 
Segment intersection_with (const Triangle &t) const
 Computes the intersection segment with a triangle.
 
Segment intersection_with (const Ellipse &e) const
 Computes the intersection segment with an ellipse.
 
- Public Member Functions inherited from Aleph::Geom_Object
 Geom_Object ()=default
 
virtual ~Geom_Object ()=default
 

Private Member Functions

double compute_slope () const
 Internal helper to compute the slope as a double.
 

Static Private Member Functions

static Point compute_tgt_point (const Point &src, const Geom_Number &m, const Geom_Number &d)
 Computes the target point of a segment given a source, slope, and length.
 

Private Attributes

Point src_
 
Point tgt_
 

Friends

class Point
 
class Triangle
 

Detailed Description

Represents a line segment between two points.

Represents an (undirected) segment in the plane, stored as source and target endpoints. Provides methods for intersection, projection, distance calculations, and other geometric queries.

Definition at line 826 of file point.H.

Member Enumeration Documentation

◆ Sense

Cardinal and intercardinal directions associated with a segment's vector.

Enumerator
NE 
NW 
SW 
SE 

Definition at line 1327 of file point.H.

Constructor & Destructor Documentation

◆ Segment() [1/4]

Aleph::Segment::Segment ( )
default

Default constructor.

Initializes a zero-length segment at the origin.

Referenced by intersection_with(), and intersects_with().

◆ Segment() [2/4]

Aleph::Segment::Segment ( Point  src,
Point  tgt 
)
inline

Constructs a segment from two endpoints.

Parameters
srcThe source point.
tgtThe target point.

Definition at line 933 of file point.H.

◆ Segment() [3/4]

Aleph::Segment::Segment ( Point  src,
const Geom_Number m,
const Geom_Number l 
)
inline

Constructs a new segment from a source point, slope, and length.

It computes the target point by solving the system of equations for a line and distance.

Parameters
srcThe source point.
mThe slope (rise over run).
lThe length of the segment.

Definition at line 972 of file point.H.

◆ Segment() [4/4]

Aleph::Segment::Segment ( const Segment sg,
const Geom_Number dist 
)
inline

Constructs a new segment parallel to a given segment at a specified distance.

Parameters
sgThe reference segment.
distThe perpendicular distance to the new segment.

Definition at line 983 of file point.H.

References Aleph::divide_and_conquer_partition_dp(), get_src_point(), get_tgt_point(), mid_perpendicular(), mid_point(), src_, and tgt_.

Member Function Documentation

◆ at()

Point Aleph::Segment::at ( const Geom_Number t) const
inline

Evaluates a point on the segment via linear interpolation.

Parameters
tThe interpolation parameter. t=0 returns the source, t=1 returns the target.
Returns
The Point at parameter t.

Definition at line 1137 of file point.H.

References Aleph::Point::lerp(), src_, and tgt_.

Referenced by Aleph::Ellipse::intersection_with(), and project().

◆ compute_slope()

double Aleph::Segment::compute_slope ( ) const
inlineprivate

Internal helper to compute the slope as a double.

Returns
The slope of the segment. Returns +/- infinity for vertical segments.

Definition at line 837 of file point.H.

References Aleph::divide_and_conquer_partition_dp(), __gmp_expr< mpq_t, mpq_t >::get_d(), Aleph::Point::get_x(), Aleph::Point::get_y(), src_, and tgt_.

Referenced by slope().

◆ compute_tgt_point()

static Point Aleph::Segment::compute_tgt_point ( const Point src,
const Geom_Number m,
const Geom_Number d 
)
inlinestaticprivate

Computes the target point of a segment given a source, slope, and length.

Parameters
srcThe origin point.
mThe slope.
dThe length of the segment.
Returns
The calculated target point, placed to the east (right).

Definition at line 948 of file point.H.

References Aleph::divide_and_conquer_partition_dp(), Aleph::Point::get_x(), Aleph::Point::get_y(), m, Aleph::square_root(), and y.

◆ contains() [1/2]

bool Aleph::Segment::contains ( const Point p) const
inline

Checks if a point lies on this segment.

Parameters
pThe point to check.
Returns
true if p is collinear and lies between the endpoints.

Definition at line 1246 of file point.H.

References Aleph::Point::is_between(), src_, and tgt_.

Referenced by contains(), contains_to(), contains_to(), intersection_with(), intersects_with(), Aleph::Point::is_inside(), Aleph::TrapezoidalMapPointLocation::Result::locate(), Aleph::ConstrainedDelaunayTriangulation::map_constraints(), Aleph::on_segment(), Aleph::BooleanPolygonOperations::point_inside_ccw(), and TEST_F().

◆ contains() [2/2]

bool Aleph::Segment::contains ( const Segment s) const
inline

Checks if another segment s lies entirely inside this segment.

Parameters
sThe other segment.
Returns
true if both endpoints of s are on this segment.

Definition at line 1260 of file point.H.

References Aleph::and, contains(), get_src_point(), and get_tgt_point().

◆ contains_to() [1/2]

bool Aleph::Segment::contains_to ( const Point p) const
inline
Deprecated:
Use contains() instead.

Definition at line 1253 of file point.H.

References contains().

◆ contains_to() [2/2]

bool Aleph::Segment::contains_to ( const Segment s) const
inline
Deprecated:
Use contains() instead.

Definition at line 1267 of file point.H.

References contains().

◆ counterclockwise_angle()

double Aleph::Segment::counterclockwise_angle ( ) const
inline

Computes the counter-clockwise angle of this segment with respect to the x-axis.

Returns
The angle in radians, in the range [0, 2*PI).

Definition at line 1046 of file point.H.

References Aleph::divide_and_conquer_partition_dp(), and Point.

Referenced by TEST_F().

◆ counterclockwise_angle_with()

double Aleph::Segment::counterclockwise_angle_with ( const Segment s) const
inline

Computes the counter-clockwise rotation angle FROM this segment TO another.

Returns the angle (in radians) you would rotate this segment counter-clockwise to align it with segment s. For example, if this segment points along +X and s points along +Y, the result is π/2 (90°).

Parameters
sThe target segment.
Returns
The angle in radians, in the range [0, 2*PI).

Definition at line 1025 of file point.H.

References Aleph::arctan2(), Aleph::divide_and_conquer_partition_dp(), Aleph::geom_number_to_double(), Aleph::geom_pi(), Aleph::Point::get_x(), Aleph::Point::get_y(), src_, tgt_, and y1().

◆ distance_to()

Geom_Number Aleph::Segment::distance_to ( const Point p) const
inline

Calculates the Euclidean distance from a point to this segment.

Parameters
pThe point.
Returns
The shortest distance from p to any point on the segment.

Definition at line 1169 of file point.H.

References Aleph::Point::distance_to(), and project().

Referenced by Aleph::DouglasPeuckerSimplification::dp_recurse(), and TEST_F().

◆ enlarge_src()

void Aleph::Segment::enlarge_src ( const Geom_Number dist)
inline

Extends the segment by a given distance from the source endpoint.

Parameters
distThe distance to extend.

Definition at line 1361 of file point.H.

References src_, and tgt_.

Referenced by TEST_F().

◆ enlarge_tgt()

void Aleph::Segment::enlarge_tgt ( const Geom_Number dist)
inline

Extends the segment by a given distance from the target endpoint.

Parameters
distThe distance to extend.

Definition at line 1371 of file point.H.

References src_, and tgt_.

Referenced by TEST_F().

◆ get_perpendicular()

Segment Aleph::Segment::get_perpendicular ( const Point p) const
inline

Constructs a segment perpendicular to this that passes through point p.

Parameters
pThe point through which the perpendicular segment will pass.
Returns
A new Segment starting at the projected point on this segment's line and ending at p.

Definition at line 1190 of file point.H.

References ah_domain_error_if, Aleph::divide_and_conquer_partition_dp(), Aleph::Point::dot(), Aleph::Point::lerp(), src_, and tgt_.

Referenced by TEST_F().

◆ get_src_point()

const Point & Aleph::Segment::get_src_point ( ) const
inlinenoexcept

Gets the source point of the segment.

Returns
A const reference to the source point.

Definition at line 915 of file point.H.

References src_.

Referenced by Segment(), Aleph::SweepLineSegmentIntersection::canonicalize(), Aleph::Polygon::centroid(), Aleph::SegmentSegmentIntersection::collinear_overlap(), Aleph::TrapezoidalMapPointLocation::Result::contains(), contains(), Aleph::CuttingEarsTriangulation::diagonalize(), Aleph::Tikz_Plane::draw_segment(), Aleph::QuickHull::get_farthest_point(), Aleph::RotatedEllipse::intersection_with(), Aleph::Ellipse::intersection_with(), intersection_with(), Aleph::Ellipse::intersects_with(), Aleph::RotatedEllipse::intersects_with(), Aleph::TrapezoidalMapPointLocation::Result::locate(), Aleph::Polygon::locate_point(), Aleph::ConstrainedDelaunayTriangulation::map_constraints(), Aleph::ConstrainedDelaunayTriangulation::merge_and_deduplicate(), nearest_point(), Aleph::TrapezoidalMapPointLocation::operator()(), Aleph::BruteForceConvexHull::operator()(), Aleph::operator<<(), Aleph::TrapezoidalMapPointLocation::point_above_segment(), print_case(), Aleph::put_trapezoidal_map_result(), Aleph::Polygon::signed_area(), Aleph::SweepLineSegmentIntersection::slope_less(), Aleph::TrapezoidalMapPointLocation::split_multiple_trapezoids(), Aleph::TrapezoidalMapPointLocation::split_single_trapezoid(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), Aleph::GeomSerializer::to_geojson(), Aleph::GeomSerializer::to_wkt(), and Aleph::SweepLineSegmentIntersection::y_at_x().

◆ get_tgt_point()

const Point & Aleph::Segment::get_tgt_point ( ) const
inlinenoexcept

Gets the target point of the segment.

Returns
A const reference to the target point.

Definition at line 921 of file point.H.

References tgt_.

Referenced by Segment(), Aleph::SweepLineSegmentIntersection::canonicalize(), Aleph::Polygon::centroid(), Aleph::TrapezoidalMapPointLocation::Result::contains(), contains(), Aleph::CuttingEarsTriangulation::diagonalize(), Aleph::Tikz_Plane::draw_segment(), Aleph::TrapezoidalMapPointLocation::find_crossed_trapezoids(), Aleph::QuickHull::get_farthest_point(), Aleph::Regular_Polygon::get_vertex(), Aleph::RotatedEllipse::intersection_with(), Aleph::Ellipse::intersection_with(), intersection_with(), Aleph::Ellipse::intersects_with(), Aleph::RotatedEllipse::intersects_with(), Aleph::TrapezoidalMapPointLocation::Result::locate(), Aleph::Polygon::locate_point(), Aleph::ConstrainedDelaunayTriangulation::map_constraints(), Aleph::ConstrainedDelaunayTriangulation::merge_and_deduplicate(), nearest_point(), Aleph::BruteForceConvexHull::operator()(), Aleph::operator<<(), Aleph::TrapezoidalMapPointLocation::point_above_segment(), print_case(), Aleph::put_trapezoidal_map_result(), Aleph::Polygon::signed_area(), Aleph::SweepLineSegmentIntersection::slope_less(), Aleph::TrapezoidalMapPointLocation::split_multiple_trapezoids(), Aleph::TrapezoidalMapPointLocation::split_single_trapezoid(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), Aleph::GeomSerializer::to_geojson(), Aleph::GeomSerializer::to_wkt(), and Aleph::SweepLineSegmentIntersection::y_at_x().

◆ highest_point()

const Point & Aleph::Segment::highest_point ( ) const
inlinenoexcept

Gets the endpoint with the largest y-coordinate.

Returns
A const reference to the highest point.

Definition at line 879 of file point.H.

References Aleph::Point::get_y(), src_, and tgt_.

Referenced by Aleph::Tikz_Plane::bbox_of().

◆ intersection_with() [1/3]

Segment Aleph::Segment::intersection_with ( const Ellipse e) const
inline

Computes the intersection segment with an ellipse.

Parameters
eThe ellipse.
Returns
The Segment of intersection. Can be a point for tangency.
Exceptions
std::domain_errorif there is no intersection.

Definition at line 2379 of file point.H.

References Aleph::Ellipse::intersection_with().

◆ intersection_with() [2/3]

Point Aleph::Segment::intersection_with ( const Segment s) const
inline

Computes the intersection point of the infinite lines defined by two segments.

Parameters
sThe other segment.
Returns
The Point of intersection.
Exceptions
std::domain_errorif the segments are parallel.

Definition at line 1313 of file point.H.

References ah_domain_error_if, Aleph::Point::cross(), src_, and tgt_.

Referenced by arc_segment(), arc_trigon(), Aleph::PolygonOffset::find_self_intersections(), Aleph::BooleanPolygonOperations::greiner_hormann(), Aleph::Triangle::intersection_with(), intersection_with(), and main().

◆ intersection_with() [3/3]

Segment Aleph::Segment::intersection_with ( const Triangle t) const
inline

Computes the intersection segment with a triangle.

Parameters
tThe triangle.
Returns
The Segment of intersection. Can be a point (degenerate segment).
Exceptions
std::domain_errorif there is no intersection.

Definition at line 1933 of file point.H.

References Segment(), ah_domain_error_if, contains(), Aleph::count(), Aleph::divide_and_conquer_partition_dp(), Aleph::Triangle::get_p1(), Aleph::Triangle::get_p2(), Aleph::Triangle::get_p3(), get_src_point(), get_tgt_point(), intersection_with(), intersects_with(), and is_parallel_with().

◆ intersects_properly_with()

bool Aleph::Segment::intersects_properly_with ( const Segment s) const
inline

Checks if this segment properly intersects another segment.

A proper intersection means the segments cross at an interior point, and do not share any endpoints or overlap collinearly.

Parameters
sThe other segment.
Returns
true if they properly intersect.

Definition at line 1228 of file point.H.

References Aleph::and, Aleph::area_of_parallelogram(), src_, and tgt_.

Referenced by Aleph::ConstrainedDelaunayTriangulation::find_crossing_edges(), Aleph::PolygonOffset::find_self_intersections(), Aleph::BooleanPolygonOperations::greiner_hormann(), intersects_with(), Aleph::ShortestPathInPolygon::operator()(), Aleph::detail::shortest_path_portals(), TEST_F(), TEST_F(), and TEST_F().

◆ intersects_with() [1/3]

bool Aleph::Segment::intersects_with ( const Ellipse e) const
inline

Checks if this segment intersects an ellipse.

Parameters
eThe ellipse.
Returns
true if the segment and ellipse share at least one point.

Definition at line 2372 of file point.H.

References Aleph::Ellipse::intersects_with().

◆ intersects_with() [2/3]

bool Aleph::Segment::intersects_with ( const Segment s) const
inline

Checks if this segment intersects another one (including endpoints and collinear overlap).

Parameters
sThe other segment.
Returns
true if they share at least one point.

Definition at line 1274 of file point.H.

References contains(), Aleph::divide_and_conquer_partition_dp(), intersects_properly_with(), src_, and tgt_.

Referenced by Aleph::CuttingEarsTriangulation::diagonalize(), intersection_with(), intersects_with(), and Aleph::segments_intersect().

◆ intersects_with() [3/3]

bool Aleph::Segment::intersects_with ( const Triangle t) const
inline

Checks if this segment intersects a triangle.

Parameters
tThe triangle.
Returns
true if the segment and triangle share at least one point.

Definition at line 1922 of file point.H.

References Segment(), Aleph::divide_and_conquer_partition_dp(), Aleph::Triangle::get_p1(), Aleph::Triangle::get_p2(), Aleph::Triangle::get_p3(), and intersects_with().

◆ is_colinear_with()

bool Aleph::Segment::is_colinear_with ( const Point p) const
inline

Checks if a point is collinear with this segment.

Parameters
pThe point to check.
Returns
true if the point lies on the infinite line defined by this segment.

Definition at line 1070 of file point.H.

References Aleph::Point::is_colinear_with(), src_, and tgt_.

Referenced by TEST_F().

◆ is_left_of()

bool Aleph::Segment::is_left_of ( const Point p) const
inline

Checks if this segment is to the left of a given point.

Parameters
pThe point.
Returns
true if the point is to the right of this directed segment.
See also
Point::is_right_of()

Definition at line 1081 of file point.H.

References Aleph::Point::is_right_of().

Referenced by is_to_left_from(), and TEST_F().

◆ is_parallel_with()

bool Aleph::Segment::is_parallel_with ( const Segment s) const
inline

Checks if this segment is parallel to another one.

Parameters
sThe other segment.
Returns
true if their direction vectors are parallel (cross product is zero).

Definition at line 1302 of file point.H.

References src_, and tgt_.

Referenced by intersection_with().

◆ is_right_of()

bool Aleph::Segment::is_right_of ( const Point p) const
inline

Checks if this segment is to the right of a given point.

Parameters
pThe point.
Returns
true if the point is to the left of this directed segment.
See also
Point::is_left_of()

Definition at line 1092 of file point.H.

References Aleph::Point::is_left_of().

Referenced by is_to_right_from(), and TEST_F().

◆ is_to_left_from()

bool Aleph::Segment::is_to_left_from ( const Point p) const
inline
Deprecated:
Use is_left_of() instead.

Definition at line 1099 of file point.H.

References is_left_of().

◆ is_to_right_from()

bool Aleph::Segment::is_to_right_from ( const Point p) const
inline
Deprecated:
Use is_right_of() instead.

Definition at line 1106 of file point.H.

References is_right_of().

◆ leftmost_point()

const Point & Aleph::Segment::leftmost_point ( ) const
inlinenoexcept

Gets the endpoint with the smallest x-coordinate.

Returns
A const reference to the leftmost point.

Definition at line 897 of file point.H.

References Aleph::Point::get_x(), src_, and tgt_.

Referenced by Aleph::Tikz_Plane::bbox_of().

◆ length()

Geom_Number Aleph::Segment::length ( ) const
inline

Returns the Euclidean length of the segment.

Returns
The distance between the segment's endpoints.

Definition at line 1056 of file point.H.

References Aleph::euclidean_distance(), Aleph::Point::get_x(), Aleph::Point::get_y(), src_, and tgt_.

Referenced by demo_coverage_area(), size(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ lowest_point()

const Point & Aleph::Segment::lowest_point ( ) const
inlinenoexcept

Gets the endpoint with the smallest y-coordinate.

Returns
A const reference to the lowest point.

Definition at line 888 of file point.H.

References Aleph::Point::get_y(), src_, and tgt_.

Referenced by Aleph::Tikz_Plane::bbox_of().

◆ mid_perpendicular()

Segment Aleph::Segment::mid_perpendicular ( const Geom_Number dist) const
inline

Returns the perpendicular chord of a given length passing through the midpoint.

Parameters
distThe half-length of the perpendicular chord. The total length will be 2*dist.
Returns
A Segment perpendicular to this one, centered on its midpoint.
Exceptions
std::domain_errorif this segment has zero length.

Definition at line 1212 of file point.H.

References Aleph::divide_and_conquer_partition_dp(), Aleph::Point::get_x(), Aleph::Point::get_y(), mid_point(), src_, and tgt_.

Referenced by Segment(), main(), and TEST().

◆ mid_point()

Point Aleph::Segment::mid_point ( ) const
inline

Returns the midpoint of this segment.

Returns
A Point representing the midpoint.

Definition at line 1115 of file point.H.

References Aleph::Point::get_x(), Aleph::Point::get_y(), src_, tgt_, and y.

Referenced by Segment(), mid_perpendicular(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ nearest_point()

const Point & Aleph::Segment::nearest_point ( const Point p) const
inline

Returns whichever endpoint of this segment is nearer to a given point.

Parameters
pThe reference point.
Returns
A const reference to the nearest endpoint (src_ or tgt_).

Definition at line 1180 of file point.H.

References get_src_point(), get_tgt_point(), and Aleph::Point::nearest_point().

◆ operator std::string()

Aleph::Segment::operator std::string ( ) const
inline

Cast operator to std::string.

Definition at line 1389 of file point.H.

References to_string().

◆ operator!=()

bool Aleph::Segment::operator!= ( const Segment s) const
inlinenoexcept

Checks for inequality between two segments.

Parameters
sThe other segment to compare.
Returns
true if segments are not equal.

Definition at line 870 of file point.H.

References Aleph::divide_and_conquer_partition_dp().

◆ operator==()

bool Aleph::Segment::operator== ( const Segment s) const
inlinenoexcept

Checks for equality between two segments.

Note
Segments are considered equal if their endpoints are the same, regardless of direction (src/tgt).
Parameters
sThe other segment to compare.
Returns
true if segments are equal, false otherwise.

Definition at line 859 of file point.H.

References Aleph::and, Aleph::divide_and_conquer_partition_dp(), src_, and tgt_.

◆ project()

Point Aleph::Segment::project ( const Point p) const
inline

Orthogonal projection of a point onto this segment's infinite line, clamped to the segment's endpoints.

Parameters
pThe point to project.
Returns
The closest point on the segment to p.

Definition at line 1147 of file point.H.

References at(), Aleph::divide_and_conquer_partition_dp(), Aleph::Point::dot(), src_, and tgt_.

Referenced by brute_convex_distance_squared(), distance_to(), Aleph::ConvexPolygonDistanceGJK::exact_refine_disjoint(), and TEST_F().

◆ reversed()

Segment Aleph::Segment::reversed ( ) const
inline

Returns a new segment with the endpoints swapped.

Returns
A Segment with source and target points reversed.

Definition at line 1127 of file point.H.

References src_, and tgt_.

Referenced by TEST_F().

◆ rightmost_point()

const Point & Aleph::Segment::rightmost_point ( ) const
inlinenoexcept

Gets the endpoint with the largest x-coordinate.

Returns
A const reference to the rightmost point.

Definition at line 906 of file point.H.

References Aleph::Point::get_x(), src_, and tgt_.

Referenced by Aleph::Tikz_Plane::bbox_of().

◆ rotate()

void Aleph::Segment::rotate ( const Geom_Number angle)
inline

Rotates the segment by a given angle around its source point.

Parameters
angleThe angle of rotation in radians.

Definition at line 1398 of file point.H.

References Aleph::divide_and_conquer_partition_dp(), rotate(), src_, and tgt_.

Referenced by Aleph::Regular_Polygon::get_vertex(), and rotate().

◆ sense()

Sense Aleph::Segment::sense ( ) const
inline

Determines the cardinal/intercardinal direction of the segment.

Returns
The Sense enum value representing the direction from source to target.

Definition at line 1333 of file point.H.

References E, Aleph::Point::get_x(), Aleph::Point::get_y(), N, NE, NW, S, SE, src_, SW, tgt_, and W.

◆ size()

Geom_Number Aleph::Segment::size ( ) const
inline
Deprecated:
Use length() instead.

Definition at line 1063 of file point.H.

References length().

◆ slope()

double Aleph::Segment::slope ( ) const
inline

Returns the slope of the segment.

Returns
The slope as a double. Returns +/- infinity for vertical lines.

Definition at line 999 of file point.H.

References compute_slope().

Referenced by TEST_F().

◆ slope_exact()

Geom_Number Aleph::Segment::slope_exact ( ) const
inline

Returns the exact slope of the segment as a Geom_Number.

Returns
The exact rational slope.
Exceptions
std::domain_errorif the segment is vertical.

Definition at line 1009 of file point.H.

References ah_domain_error_if, Aleph::Point::get_x(), Aleph::Point::get_y(), src_, and tgt_.

◆ to_string()

std::string Aleph::Segment::to_string ( ) const
inline

Returns a string representation of the segment, e.g., "(x1,y1)(x2,y2)".

Returns
A std::string representing the segment.

Definition at line 1381 of file point.H.

References src_, tgt_, and Aleph::Point::to_string().

Referenced by operator std::string().

Friends And Related Symbol Documentation

◆ Point

friend class Point
friend

Definition at line 828 of file point.H.

Referenced by counterclockwise_angle().

◆ Triangle

Definition at line 829 of file point.H.

Member Data Documentation

◆ src_

◆ tgt_


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