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

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

#include <easy3d/core/line.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 > thisclass
 The type of this class.
 

Public Member Functions

 GenericLine ()=default
 Default constructor.
 
void set (const Point &p, const Vector &dir)
 Sets a line from a point p and its direction dir.
 
const Vectordirection () const
 Returns the direction of the line.
 
const Pointpoint () const
 Returns an arbitrary point on the line.
 
Point projection (const Point &p) const
 Returns the projection of a point p on this line.
 
FT squared_distance (const Point &p) const
 Returns the squared distance of a point p to this line.
 
bool feet (const thisclass &other, Point &p1, Point &p2) const
 Computes the perpendicular feet with another line.
 

Static Public Member Functions

static GenericLine from_point_and_direction (const Point &p, const Vector &dir)
 Constructs a line from a point p and its direction dir.
 
static GenericLine from_two_points (const Point &p, const Point &q)
 Constructs a line from two points p and q.
 

Detailed Description

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

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

Template Parameters
DIMThe dimension of the line (2 or 3).
FTThe type of the floating-point number (float or double).

Member Function Documentation

◆ direction()

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

Returns the direction of the line.

Returns
The direction vector of the line.

◆ feet()

template<int DIM, typename FT>
bool feet ( const thisclass & other,
Point & p1,
Point & p2 ) const

Computes the perpendicular feet with another line.

Parameters
otherAnother line.
p1The perpendicular foot on the current line.
p2The perpendicular foot on the other line.
Returns
True if the perpendicular feet exist, false if the two lines are parallel.
Note
This function is for 3D only.

◆ from_point_and_direction()

template<int DIM, typename FT>
static GenericLine from_point_and_direction ( const Point & p,
const Vector & dir )
inlinestatic

Constructs a line from a point p and its direction dir.

Parameters
pThe point on the line.
dirThe direction of the line.
Returns
A GenericLine object.

◆ from_two_points()

template<int DIM, typename FT>
static GenericLine from_two_points ( const Point & p,
const Point & q )
inlinestatic

Constructs a line from two points p and q.

Parameters
pThe first point on the line.
qThe second point on the line.
Returns
A GenericLine object.

◆ point()

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

Returns an arbitrary point on the line.

Returns
The point on the line.

◆ projection()

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

Returns the projection of a point p on this line.

Parameters
pThe point to project.
Returns
The projection of the point on the line.

◆ set()

template<int DIM, typename FT>
void set ( const Point & p,
const Vector & dir )
inline

Sets a line from a point p and its direction dir.

Parameters
pThe point on the line.
dirThe direction of the line.

◆ 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 line.

Parameters
pThe point to measure the distance to.
Returns
The squared distance of the point to the line.

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