|
| Segment2D ()=default |
| Default constructor for the segment.
|
|
| Segment2D (Segment2D< Real > const &S) |
| Copy constructor for the segment.
|
|
| Segment2D (Point2D< Real > const &A, Point2D< Real > const &B) |
| Constructor to create a segment from two points.
|
|
void | setup (Point2D< Real > const &A, Point2D< Real > const &B) |
| Setup the endpoints of the segment using Point2D objects.
|
|
void | setup (Real const A[], Real const B[]) |
| Setup the endpoints of the segment using arrays.
|
|
bool | projection (Point2D< Real > const &P, Real &s) const |
| Projects a point onto the segment.
|
|
Point2D< Real > | projection (Point2D< Real > const &P, Real &s, Real &t) const |
| Projects a point onto the segment and returns the projected point.
|
|
Point2D< Real > | eval (Real &s) const |
| Evaluates the segment at a given parameter s .
|
|
Point2D< Real > | eval (Real &s, Real &t) const |
| Evaluates the segment based on two parameters s and t .
|
|
Point2D< Real > const & | Pa () const |
| Returns the first endpoint of the segment.
|
|
Point2D< Real > const & | Pb () const |
| Returns the second endpoint of the segment.
|
|
void | bbox (Point2D< Real > &pmin, Point2D< Real > &pmax) const |
| Computes the bounding box of the segment.
|
|
bool | intersect (Segment2D< Real > const &S, Real &s, Real &t) const |
| Checks for intersection with another segment.
|
|
template<typename Real>
class Utils::Segment2D< Real >
A class representing a 2D line segment defined by two endpoints.
The Segment2D
class encapsulates a line segment in a two-dimensional space, defined by two points, \( P_a \) and \( P_b \). It provides methods for setting the endpoints, projecting points onto the segment, evaluating points on the segment, and checking for intersections with other segments.
- Template Parameters
-
Real | The data type used for the coordinates of the segment's endpoints, typically a floating-point type (e.g., float, double). |
Features
- Construction: Supports various constructors for initializing the segment.
- Setup: Methods to set or update the endpoints of the segment.
- Projection: Projects a point onto the segment and returns the corresponding scalar parameter.
- Evaluation: Computes points on the segment based on parameter values.
- Bounding Box: Computes the bounding box of the segment.
- Intersection: Checks for intersection with another segment and computes parameters.
Methods
- Segment2D():
- Default constructor that initializes an empty segment.
- Segment2D(Segment2D<Real> const & S):
- Copy constructor that initializes a segment as a copy of another segment.
- Segment2D(Point2D<Real> const & A, Point2D<Real> const & B):
- Constructs a segment from two given points A and B.
- void setup(Point2D<Real> const & A, Point2D<Real> const & B):
- Sets the endpoints of the segment to the given points A and B.
- void setup(Real const A[], Real const B[]):
- Sets the endpoints of the segment using arrays representing the coordinates of A and B.
- bool projection(Point2D<Real> const & P, Real & s) const:
- Projects the point P onto the segment and returns the corresponding parameter
s
.
- Returns
true
if the projection is successful, false
otherwise.
- Point2D<Real> projection(Point2D<Real> const & P, Real & s, Real & t) const:
- Projects the point P onto the segment and returns the projected point.
- Also returns the parameters
s
and t
related to the projections on the segments.
- Point2D<Real> eval(Real & s) const:
- Evaluates the segment at the parameter
s
and returns the corresponding point on the segment.
- Point2D<Real> eval(Real & s, Real & t) const:
- Evaluates the segment based on parameters
s
and t
and returns the corresponding point.
- Point2D<Real> const & Pa() const:
- Returns the first endpoint \( P_a \) of the segment.
- Point2D<Real> const & Pb() const:
- Returns the second endpoint \( P_b \) of the segment.
- void bbox(Point2D<Real> & pmin, Point2D<Real> & pmax) const:
- Computes the bounding box of the segment and updates
pmin
and pmax
with the minimum and maximum points.
- bool intersect(Segment2D<Real> const & S, Real & s, Real & t) const:
- Checks if the current segment intersects with another segment S.
- If they intersect, returns
true
and updates parameters s
and t
with the intersection information.
Usage
#include "Point2D.h"
Real param;
segment.projection(P, param);
Real s = 0.5;
A class representing a 2D point in space.
Definition Utils_GG2D.hh:98
P2D const & to_eigen() const
Definition Utils_GG2D.hh:106
Segment2D()=default
Default constructor for the segment.