A three dimensional line segment. The line is defined by a start and end point. More...
#include <gz/math/Line3.hh>
Public Member Functions | |
Line3 ()=default | |
Line Constructor. More... | |
Line3 (const double _x1, const double _y1, const double _x2, const double _y2) | |
2D Constructor where Z coordinates are 0 More... | |
Line3 (const double _x1, const double _y1, const double _z1, const double _x2, const double _y2, const double _z2) | |
Constructor. More... | |
Line3 (const Line3< T > &_line)=default | |
Copy constructor. More... | |
Line3 (const math::Vector3< T > &_ptA, const math::Vector3< T > &_ptB) | |
Constructor. More... | |
bool | Coplanar (const Line3< T > &_line, const double _epsilon=1e-6) const |
Test if this line and the given line are coplanar. More... | |
math::Vector3< T > | Direction () const |
Get the direction of the line. More... | |
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. More... | |
T | Distance (const Vector3< T > &_pt) |
Calculate shortest distance between line and point. More... | |
bool | Intersect (const Line3< T > &_line, double _epsilon=1e-6) const |
Check if this line intersects the given line segment. More... | |
bool | Intersect (const Line3< T > &_line, math::Vector3< T > &_pt, double _epsilon=1e-6) const |
Check if this line intersects the given line segment. The point of intersection is returned in the _pt parameter. More... | |
T | Length () const |
Get the length of the line. More... | |
bool | operator!= (const Line3< T > &_line) const |
Inequality operator. More... | |
Line3 & | operator= (const Line3< T > &_line)=default |
Assignment operator. More... | |
bool | operator== (const Line3< T > &_line) const |
Equality operator. More... | |
math::Vector3< T > | operator[] (const size_t _index) const |
Get the start or end point. More... | |
bool | Parallel (const Line3< T > &_line, const double _epsilon=1e-6) const |
Test if this line and the given line are parallel. More... | |
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. More... | |
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. More... | |
void | Set (const math::Vector3< T > &_ptA, const math::Vector3< T > &_ptB) |
Set the start and end point of the line segment. More... | |
void | SetA (const math::Vector3< T > &_ptA) |
Set the start point of the line segment. More... | |
void | SetB (const math::Vector3< T > &_ptB) |
Set the end point of the line segment. More... | |
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. More... | |
Detailed Description
template<typename T>
class gz::math::Line3< T >
A three dimensional line segment. The line is defined by a start and end point.
Constructor & Destructor Documentation
◆ Line3() [1/5]
|
default |
Line Constructor.
◆ Line3() [2/5]
◆ Line3() [3/5]
|
inline |
Constructor.
- Parameters
-
[in] _ptA Start point of the line segment [in] _ptB End point of the line segment
References Line3< T >::Set().
◆ Line3() [4/5]
|
inline |
2D Constructor where Z coordinates are 0
- Parameters
-
[in] _x1 X coordinate of the start point. [in] _y1 Y coordinate of the start point. [in] _x2 X coordinate of the end point. [in] _y2 Y coordinate of the end point.
References Line3< T >::Set().
◆ Line3() [5/5]
|
inline |
Constructor.
- Parameters
-
[in] _x1 X coordinate of the start point. [in] _y1 Y coordinate of the start point. [in] _z1 Z coordinate of the start point. [in] _x2 X coordinate of the end point. [in] _y2 Y coordinate of the end point. [in] _z2 Z coordinate of the end point.
References Line3< T >::Set().
Member Function Documentation
◆ Coplanar()
|
inline |
Test if this line and the given line are coplanar.
- Parameters
-
[in] _line Line to check against. [in] _epsilon The error bounds within which the check will return true.
- Returns
- True if the two lines are coplanar.
◆ Direction()
|
inline |
Get the direction of the line.
- Returns
- The direction vector
◆ Distance() [1/2]
|
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] _line Line to compare against this. [out] _result The shortest line between _line and this. [in] _epsilon Error tolerance.
- Returns
- True if a solution was found. False if a solution is not possible.
References gz::math::clamp(), Vector3< T >::Dot(), Line3< T >::Set(), Line3< T >::SetA(), Line3< T >::SetB(), Vector3< T >::X(), Vector3< T >::Y(), and Vector3< T >::Z().
Referenced by Line3< T >::Intersect().
◆ Distance() [2/2]
|
inline |
Calculate shortest distance between line and point.
- Parameters
-
[in] _pt Point which we are measuring distance to.
- Returns
- Distance from point to line.
References Vector3< T >::Length().
◆ Intersect() [1/2]
|
inline |
Check if this line intersects the given line segment.
- Parameters
-
[in] _line The line to check for intersection. [in] _epsilon The error bounds within which the intersection check will return true.
- Returns
- True if an intersection was found.
Referenced by Triangle3< T >::Intersects().
◆ Intersect() [2/2]
|
inline |
Check if this line intersects the given line segment. The point of intersection is returned in the _pt parameter.
- Parameters
-
[in] _line The line to check for intersection. [out] _pt The point of intersection. This value is only valid if the return value is true. [in] _epsilon The error bounds within which the intersection check will return true.
- Returns
- True if an intersection was found.
References Line3< T >::Distance(), Line3< T >::Length(), Line3< T >::Parallel(), and Line3< T >::Within().
◆ Length()
|
inline |
Get the length of the line.
- Returns
- The length of the line.
Referenced by Line3< T >::Intersect(), and Triangle3< T >::Intersects().
◆ operator!=()
|
inline |
Inequality operator.
- Parameters
-
[in] _line Line to compare for inequality.
- Returns
- True if the given line is not to this line
◆ operator=()
Assignment operator.
- Parameters
-
[in] _line a new value
- Returns
- this
◆ operator==()
|
inline |
Equality operator.
- Parameters
-
[in] _line Line to compare for equality.
- Returns
- True if the given line is equal to this line
◆ operator[]()
|
inline |
Get the start or end point.
- Parameters
-
[in] _index 0 = start point, 1 = end point. The _index parameter is clamped to the range [0, 1].
References gz::math::clamp(), gz::math::GZ_ONE_SIZE_T, and gz::math::GZ_ZERO_SIZE_T.
◆ Parallel()
|
inline |
Test if this line and the given line are parallel.
- Parameters
-
[in] _line Line to check against. [in] _epsilon The error bounds within which the check will return true.
- Returns
- True if the two lines are parallel.
Referenced by Line3< T >::Intersect().
◆ Set() [1/3]
|
inline |
Set the start and end point of the line segment, assuming that both points have the same height.
- Parameters
-
[in] _x1 X coordinate of the start point. [in] _y1 Y coordinate of the start point. [in] _x2 X coordinate of the end point. [in] _y2 Y coordinate of the end point. [in] _z Z coordinate of both points, by default _z is set to 0.
◆ Set() [2/3]
|
inline |
Set the start and end point of the line segment.
- Parameters
-
[in] _x1 X coordinate of the start point. [in] _y1 Y coordinate of the start point. [in] _z1 Z coordinate of the start point. [in] _x2 X coordinate of the end point. [in] _y2 Y coordinate of the end point. [in] _z2 Z coordinate of the end point.
◆ Set() [3/3]
|
inline |
Set the start and end point of the line segment.
- Parameters
-
[in] _ptA Start point of the line segment [in] _ptB End point of the line segment
Referenced by Line3< T >::Line3(), and Line3< T >::Distance().
◆ SetA()
|
inline |
Set the start point of the line segment.
- Parameters
-
[in] _ptA Start point of the line segment
Referenced by Line3< T >::Distance().
◆ SetB()
|
inline |
Set the end point of the line segment.
- Parameters
-
[in] _ptB End point of the line segment
Referenced by Line3< T >::Distance().
◆ Within()
|
inline |
Check if the given point is between the start and end points of the line segment.
- Parameters
-
[in] _pt Point to check. [in] _epsilon The error bounds within which the within check will return true.
- Returns
- True if the point is on the segement.
References std::max(), std::min(), Vector3< T >::X(), Vector3< T >::Y(), and Vector3< T >::Z().
Referenced by Line3< T >::Intersect().
The documentation for this class was generated from the following file: