Easy3D 2.6.1
Loading...
Searching...
No Matches
GenericSegment< DIM, FT > Class Template Reference

A generic segmentation representation, which supports both 2D and 3D line segments. More...

#include <easy3d/core/segment.h>

Public Types

typedef Vec< DIM, FT > Point
 The type of the point.
 
typedef Vec< DIM, FT > Vector
 The type of the vector.
 
typedef GenericLine< DIM, FT > Line
 The type of the line.
 
typedef GenericSegment< DIM, FT > thisclass
 The type of this class.
 

Public Member Functions

 GenericSegment (const Point &s, const Point &t)
 Constructs a line segment from its two end points s and t.
 
 GenericSegment ()=default
 Default constructor.
 
const Point & source () const
 Returns the source end point of this line segment.
 
const Point & target () const
 Returns the target end point of this line segment.
 
void set_source (const Point &s)
 Sets/Changes the source end point of this line segment.
 
void set_target (const Point &t)
 Sets/Changes the target end point of this line segment.
 
Line supporting_line () const
 Returns the supporting line of this line segment.
 
Vector to_vector () const
 Returns a vector originating from source() and pointing to target().
 
Point projection (const Point &p) const
 Returns the projection of a point p on the supporting line of this segment.
 
bool projected_inside (const Point &p) const
 Tests if the projection of a point p is within the two end points of this segment.
 
FT squared_distance (const Point &p) const
 Returns the squared distance of a point p to this segment.
 

Detailed Description

template<int DIM, typename FT>
class easy3d::GenericSegment< DIM, FT >

A generic segmentation representation, which supports both 2D and 3D line segments.

Template Parameters
DIMThe dimension of the space (2 or 3).
FTThe scalar type for segment coordinates.

Constructor & Destructor Documentation

◆ GenericSegment()

template<int DIM, typename FT>
GenericSegment ( const Point & s,
const Point & t )
inline

Constructs a line segment from its two end points s and t.

Parameters
sThe source end point.
tThe target end point.

Member Function Documentation

◆ projected_inside()

template<int DIM, typename FT>
bool projected_inside ( const Point & p) const
inline

Tests if the projection of a point p is within the two end points of this segment.

Parameters
pThe point to test.
Returns
true if the projection is within the segment, false otherwise.

◆ projection()

template<int DIM, typename FT>
GenericSegment< DIM, FT >::Point projection ( const Point & p) const
inline

Returns the projection of a point p on the supporting line of this segment.

Parameters
pThe point to project.
Returns
The projected point on the supporting line.

◆ set_source()

template<int DIM, typename FT>
void set_source ( const Point & s)
inline

Sets/Changes the source end point of this line segment.

Parameters
sThe new source end point.

◆ set_target()

template<int DIM, typename FT>
void set_target ( const Point & t)
inline

Sets/Changes the target end point of this line segment.

Parameters
tThe new target end point.

◆ source()

template<int DIM, typename FT>
const Point & source ( ) const
inline

Returns the source end point of this line segment.

Returns
The source end point.

◆ squared_distance()

template<int DIM, typename FT>
FT squared_distance ( const Point & p) const
inline

Returns the squared distance of a point p to this segment.

Parameters
pThe point to compute the distance to.
Returns
The squared distance to the segment. The return the value is the min of the following:
  • the squared distance between p and the supporting_line() of this segment;
  • the squared distance between p and the source() of this segment;
  • the squared distance between p and the target() of this segment.

◆ supporting_line()

template<int DIM, typename FT>
Line supporting_line ( ) const
inline

Returns the supporting line of this line segment.

Returns
The supporting line.

◆ target()

template<int DIM, typename FT>
const Point & target ( ) const
inline

Returns the target end point of this line segment.

Returns
The target end point.

◆ to_vector()

template<int DIM, typename FT>
Vector to_vector ( ) const
inline

Returns a vector originating from source() and pointing to target().

Returns
The vector from source to target.

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