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

Represents a line segment in 3D space. More...

#include <point.H>

Collaboration diagram for Aleph::Segment3D:
[legend]

Public Member Functions

 Segment3D ()=default
 Default constructor.
 
 Segment3D (const Point3D &src, const Point3D &tgt)
 Constructs a 3D segment from two endpoints.
 
const Point3Dget_src () const noexcept
 Gets the source point of the segment.
 
const Point3Dget_tgt () const noexcept
 Gets the target point of the segment.
 
const Point3Dget_src_point () const noexcept
 Gets the source point of the segment (alias for get_src).
 
const Point3Dget_tgt_point () const noexcept
 Gets the target point of the segment (alias for get_tgt).
 
Point3D direction () const
 Calculates the direction vector of the segment.
 
Geom_Number length_squared () const
 Calculates the squared length of the segment.
 
Geom_Number length () const
 Calculates the length of the segment.
 
Point3D at (const Geom_Number &t) const
 Evaluates a point on the segment via linear interpolation.
 
Point3D midpoint () const
 Calculates the midpoint of the segment.
 
bool operator== (const Segment3D &s) const
 Checks for equality between two segments.
 
bool operator!= (const Segment3D &s) const
 Checks for inequality.
 
bool contains (const Point3D &p) const
 Checks if a point lies on the segment.
 
Geom_Number distance_to (const Point3D &p) const
 Calculates the shortest distance from a point to this segment.
 

Private Attributes

Point3D src_
 
Point3D tgt_
 

Detailed Description

Represents a line segment in 3D space.

Definition at line 3213 of file point.H.

Constructor & Destructor Documentation

◆ Segment3D() [1/2]

Aleph::Segment3D::Segment3D ( )
default

Default constructor.

Initializes a zero-length segment at the origin.

◆ Segment3D() [2/2]

Aleph::Segment3D::Segment3D ( const Point3D src,
const Point3D tgt 
)
inline

Constructs a 3D segment from two endpoints.

Parameters
srcThe source point.
tgtThe target point.

Definition at line 3226 of file point.H.

Member Function Documentation

◆ at()

Point3D Aleph::Segment3D::at ( const Geom_Number t) const
inline

Evaluates a point on the segment via linear interpolation.

Parameters
tThe interpolation parameter, clamped to [0, 1]. t=0 returns src, t=1 returns tgt.
Returns
The Point3D at parameter t.

Definition at line 3266 of file point.H.

References src_, and tgt_.

Referenced by distance_to(), midpoint(), and TEST_F().

◆ contains()

bool Aleph::Segment3D::contains ( const Point3D p) const
inline

Checks if a point lies on the segment.

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

Definition at line 3309 of file point.H.

References Aleph::Point3D::cross(), direction(), Aleph::Point3D::dot(), src_, and w.

Referenced by TEST_F().

◆ direction()

Point3D Aleph::Segment3D::direction ( ) const
inline

Calculates the direction vector of the segment.

Returns
A Point3D representing the vector from source to target.

Definition at line 3241 of file point.H.

References src_, and tgt_.

Referenced by contains(), and distance_to().

◆ distance_to()

Geom_Number Aleph::Segment3D::distance_to ( const Point3D p) const
inline

Calculates the shortest distance from a point to this segment.

Parameters
pThe point.
Returns
The Euclidean distance to the closest point on the segment.

Definition at line 3331 of file point.H.

References at(), direction(), Aleph::Point3D::distance_to(), Aleph::divide_and_conquer_partition_dp(), Aleph::Point3D::dot(), and src_.

Referenced by TEST_F().

◆ get_src()

const Point3D & Aleph::Segment3D::get_src ( ) const
inlinenoexcept

Gets the source point of the segment.

Definition at line 3229 of file point.H.

References src_.

Referenced by Aleph::operator<<(), and TEST_F().

◆ get_src_point()

const Point3D & Aleph::Segment3D::get_src_point ( ) const
inlinenoexcept

Gets the source point of the segment (alias for get_src).

Definition at line 3233 of file point.H.

References src_.

◆ get_tgt()

const Point3D & Aleph::Segment3D::get_tgt ( ) const
inlinenoexcept

Gets the target point of the segment.

Definition at line 3231 of file point.H.

References tgt_.

Referenced by Aleph::operator<<(), and TEST_F().

◆ get_tgt_point()

const Point3D & Aleph::Segment3D::get_tgt_point ( ) const
inlinenoexcept

Gets the target point of the segment (alias for get_tgt).

Definition at line 3235 of file point.H.

References tgt_.

◆ length()

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

Calculates the length of the segment.

Returns
The Euclidean distance between the endpoints.

Definition at line 3256 of file point.H.

References Aleph::Point3D::distance_to(), src_, and tgt_.

Referenced by TEST_F().

◆ length_squared()

Geom_Number Aleph::Segment3D::length_squared ( ) const
inline

Calculates the squared length of the segment.

Returns
The squared Euclidean distance between the endpoints.

Definition at line 3247 of file point.H.

References Aleph::Point3D::distance_squared_to(), src_, and tgt_.

Referenced by TEST_F().

◆ midpoint()

Point3D Aleph::Segment3D::midpoint ( ) const
inline

Calculates the midpoint of the segment.

Returns
The Point3D at the midpoint.

Definition at line 3276 of file point.H.

References at().

Referenced by TEST_F().

◆ operator!=()

bool Aleph::Segment3D::operator!= ( const Segment3D s) const
inline

Checks for inequality.

Parameters
sThe other segment.
Returns
true if source or target points are different.

Definition at line 3299 of file point.H.

References Aleph::divide_and_conquer_partition_dp().

◆ operator==()

bool Aleph::Segment3D::operator== ( const Segment3D s) const
inline

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.
Returns
true if segments are equal, false otherwise.

Definition at line 3288 of file point.H.

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

Member Data Documentation

◆ src_

Point3D Aleph::Segment3D::src_
private

◆ tgt_

Point3D Aleph::Segment3D::tgt_
private

Definition at line 3215 of file point.H.

Referenced by at(), direction(), get_tgt(), get_tgt_point(), length(), length_squared(), and operator==().


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