Loading...
Searching...
No Matches
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T > Class Template Reference

A three dimensional line segment. More...

#include <ignition/math/Line3.hh>

Public Member Functions

 Line3 ()=default
 Line Constructor.
 
 Line3 (const double _x1, const double _y1, const double _x2, const double _y2)
 2D Constructor where Z coordinates are 0
 
 Line3 (const double _x1, const double _y1, const double _z1, const double _x2, const double _y2, const double _z2)
 Constructor.
 
 Line3 (const Line3< T > &_line)
 Copy constructor.
 
 Line3 (const math::Vector3< T > &_ptA, const math::Vector3< T > &_ptB)
 Constructor.
 
bool Coplanar (const Line3< T > &_line, const double _epsilon=1e-6) const
 Test if this line and the given line are coplanar.
 
math::Vector3< T > Direction () const
 Get the direction of the line.
 
bool Distance (const Line3< T > &_line, Line3< T > &_result, const double _epsilon=1e-6) const
 Get the shortest line between this line and the provided line.
 
bool Intersect (const Line3< T > &_line, double _epsilon=1e-6) const
 Check if this line intersects the given line segment.
 
bool Intersect (const Line3< T > &_line, math::Vector3< T > &_pt, double _epsilon=1e-6) const
 Check if this line intersects the given line segment.
 
Length () const
 Get the length of the line.
 
bool operator!= (const Line3< T > &_line) const
 Inequality operator.
 
Line3operator= (const Line3< T > &_line)
 Assignment operator.
 
bool operator== (const Line3< T > &_line) const
 Equality operator.
 
math::Vector3< T > operator[] (const size_t _index) const
 Get the start or end point.
 
bool Parallel (const Line3< T > &_line, const double _epsilon=1e-6) const
 Test if this line and the given line are parallel.
 
void Set (const double _x1, const double _y1, const double _x2, const double _y2, const double _z=0)
 Set the start and end point of the line segment, assuming that both points have the same height.
 
void Set (const double _x1, const double _y1, const double _z1, const double _x2, const double _y2, const double _z2)
 Set the start and end point of the line segment.
 
void Set (const math::Vector3< T > &_ptA, const math::Vector3< T > &_ptB)
 Set the start and end point of the line segment.
 
void SetA (const math::Vector3< T > &_ptA)
 Set the start point of the line segment.
 
void SetB (const math::Vector3< T > &_ptB)
 Set the end point of the line segment.
 
bool Within (const math::Vector3< T > &_pt, double _epsilon=1e-6) const
 Check if the given point is between the start and end points of the line segment.
 

Detailed Description

template<typename T>
class ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >

A three dimensional line segment.

The line is defined by a start and end point.

Constructor & Destructor Documentation

◆ Line3() [1/5]

template<typename T >
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Line3 ( )
default

Line Constructor.

◆ Line3() [2/5]

template<typename T >
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Line3 ( const Line3< T > & _line)
inline

Copy constructor.

Parameters
[in]_linea line object

◆ Line3() [3/5]

template<typename T >
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Line3 ( const math::Vector3< T > & _ptA,
const math::Vector3< T > & _ptB )
inline

Constructor.

Parameters
[in]_ptAStart point of the line segment
[in]_ptBEnd point of the line segment

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Set().

◆ Line3() [4/5]

template<typename T >
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Line3 ( const double _x1,
const double _y1,
const double _x2,
const double _y2 )
inline

2D Constructor where Z coordinates are 0

Parameters
[in]_x1X coordinate of the start point.
[in]_y1Y coordinate of the start point.
[in]_x2X coordinate of the end point.
[in]_y2Y coordinate of the end point.

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Set().

◆ Line3() [5/5]

template<typename T >
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Line3 ( const double _x1,
const double _y1,
const double _z1,
const double _x2,
const double _y2,
const double _z2 )
inline

Constructor.

Parameters
[in]_x1X coordinate of the start point.
[in]_y1Y coordinate of the start point.
[in]_z1Z coordinate of the start point.
[in]_x2X coordinate of the end point.
[in]_y2Y coordinate of the end point.
[in]_z2Z coordinate of the end point.

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Set().

Member Function Documentation

◆ Coplanar()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Coplanar ( const Line3< T > & _line,
const double _epsilon = 1e-6 ) const
inline

Test if this line and the given line are coplanar.

Parameters
[in]_lineLine to check against.
[in]_epsilonThe error bounds within which the check will return true.
Returns
True if the two lines are coplanar.

◆ Direction()

template<typename T >
math::Vector3< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Direction ( ) const
inline

Get the direction of the line.

Returns
The direction vector

◆ Distance()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Distance ( const Line3< T > & _line,
Line3< T > & _result,
const double _epsilon = 1e-6 ) const
inline

Get the shortest line between this line and the provided line.

In the case when the two lines are parallel, we choose the first point of this line and the closest point in the provided line.

Parameters
[in]_lineLine to compare against this.
[out]_resultThe shortest line between _line and this.
Returns
True if a solution was found. False if a solution is not possible.

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::clamp(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Dot(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Set(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::SetA(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::SetB(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::X(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Y(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Z().

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Intersect().

◆ Intersect() [1/2]

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Intersect ( const Line3< T > & _line,
double _epsilon = 1e-6 ) const
inline

Check if this line intersects the given line segment.

Parameters
[in]_lineThe line to check for intersection.
[in]_epsilonThe error bounds within which the intersection check will return true.
Returns
True if an intersection was found.

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Intersect().

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Intersect(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Intersects().

◆ Intersect() [2/2]

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Intersect ( const Line3< T > & _line,
math::Vector3< T > & _pt,
double _epsilon = 1e-6 ) const
inline

Check if this line intersects the given line segment.

The point of intersection is returned in the _pt parameter.

Parameters
[in]_lineThe line to check for intersection.
[out]_ptThe point of intersection. This value is only valid if the return value is true.
[in]_epsilonThe error bounds within which the intersection check will return true.
Returns
True if an intersection was found.

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Distance(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Length(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Parallel(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Within().

◆ Length()

template<typename T >
T ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Length ( ) const
inline

◆ operator!=()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::operator!= ( const Line3< T > & _line) const
inline

Inequality operator.

Parameters
[in]_lineLine to compare for inequality.
Returns
True if the given line is not to this line

◆ operator=()

template<typename T >
Line3 & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::operator= ( const Line3< T > & _line)
inline

Assignment operator.

Parameters
[in]_linea new value
Returns
this

◆ operator==()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::operator== ( const Line3< T > & _line) const
inline

Equality operator.

Parameters
[in]_lineLine to compare for equality.
Returns
True if the given line is equal to this line

◆ operator[]()

template<typename T >
math::Vector3< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::operator[] ( const size_t _index) const
inline

Get the start or end point.

Parameters
[in]_index0 = start point, 1 = end point. The _index parameter is clamped to the range [0, 1].

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::clamp(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ONE_SIZE_T, and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ZERO_SIZE_T.

◆ Parallel()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Parallel ( const Line3< T > & _line,
const double _epsilon = 1e-6 ) const
inline

Test if this line and the given line are parallel.

Parameters
[in]_lineLine to check against.
[in]_epsilonThe error bounds within which the check will return true.
Returns
True if the two lines are parallel.

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Intersect().

◆ Set() [1/3]

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Set ( const double _x1,
const double _y1,
const double _x2,
const double _y2,
const double _z = 0 )
inline

Set the start and end point of the line segment, assuming that both points have the same height.

Parameters
[in]_x1X coordinate of the start point.
[in]_y1Y coordinate of the start point.
[in]_x2X coordinate of the end point.
[in]_y2Y coordinate of the end point.
[in]_zZ coordinate of both points, by default _z is set to 0.

◆ Set() [2/3]

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Set ( const double _x1,
const double _y1,
const double _z1,
const double _x2,
const double _y2,
const double _z2 )
inline

Set the start and end point of the line segment.

Parameters
[in]_x1X coordinate of the start point.
[in]_y1Y coordinate of the start point.
[in]_z1Z coordinate of the start point.
[in]_x2X coordinate of the end point.
[in]_y2Y coordinate of the end point.
[in]_z2Z coordinate of the end point.

◆ Set() [3/3]

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Set ( const math::Vector3< T > & _ptA,
const math::Vector3< T > & _ptB )
inline

◆ SetA()

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::SetA ( const math::Vector3< T > & _ptA)
inline

Set the start point of the line segment.

Parameters
[in]_ptAStart point of the line segment

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Distance().

◆ SetB()

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::SetB ( const math::Vector3< T > & _ptB)
inline

Set the end point of the line segment.

Parameters
[in]_ptBEnd point of the line segment

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Distance().

◆ Within()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Within ( const math::Vector3< T > & _pt,
double _epsilon = 1e-6 ) const
inline

Check if the given point is between the start and end points of the line segment.

Parameters
[in]_ptPoint to check.
[in]_epsilonThe error bounds within which the within check will return true.
Returns
True if the point is on the segement.

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::X(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Y(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Z().

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Intersect().


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