A 3-dimensional triangle and related functions. More...
#include <ignition/math/Triangle3.hh>
Public Member Functions | |
Triangle3 ()=default | |
Default constructor. | |
Triangle3 (const Vector3< T > &_pt1, const Vector3< T > &_pt2, const Vector3< T > &_pt3) | |
Constructor. | |
double | Area () const |
Get the area of this triangle. | |
bool | Contains (const Line3< T > &_line) const |
Check if this triangle completely contains the given line segment. | |
bool | Contains (const Vector3< T > &_pt) const |
Get whether this triangle contains the given point. | |
bool | Intersects (const Line3< T > &_line, Vector3< T > &_ipt1) const |
Get whether the given line intersects an edge of this triangle. | |
Vector3d | Normal () const |
Get the triangle's normal vector. | |
Vector3< T > | operator[] (const size_t _index) const |
Get one of points that define the triangle. | |
T | Perimeter () const |
Get the length of the triangle's perimeter. | |
void | Set (const unsigned int _index, const Vector3< T > &_pt) |
Set one vertex of the triangle. | |
void | Set (const Vector3< T > &_pt1, const Vector3< T > &_pt2, const Vector3< T > &_pt3) |
Set all vertices of the triangle. | |
Line3< T > | Side (const unsigned int _index) const |
Get a line segment for one side of the triangle. | |
bool | Valid () const |
Get whether this triangle is valid, based on triangle inequality: the sum of the lengths of any two sides must be greater than the length of the remaining side. | |
A 3-dimensional triangle and related functions.
|
default |
Default constructor.
|
inline |
Constructor.
Keep in mind that the triangle normal is determined by the order of these vertices. Search the internet for "triangle winding" for more information.
[in] | _pt1 | First point that defines the triangle. |
[in] | _pt2 | Second point that defines the triangle. |
[in] | _pt3 | Third point that defines the triangle. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Set().
|
inline |
Get the area of this triangle.
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Perimeter(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Side().
|
inline |
Check if this triangle completely contains the given line segment.
[in] | _line | Line to check. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Contains().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Contains(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Intersects().
|
inline |
Get whether this triangle contains the given point.
[in] | _pt | Point to check. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Dot(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Plane< T >::NO_SIDE, ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Normal(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Side().
|
inline |
Get whether the given line intersects an edge of this triangle.
The returned intersection point is one of:
[in] | _line | Line to check. |
[out] | _ipt1 | Return value of the first intersection point, only valid if the return value of the function is true. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Contains(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Dot(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Intersect(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line3< T >::Length(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Normal().
|
inline |
Get the triangle's normal vector.
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Normal().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Contains(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Intersects().
|
inline |
Get one of points that define the triangle.
[in] | _index | 0, 1, or 2. _index is clamped to the range [0,2]. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::clamp(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_TWO_SIZE_T, and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ZERO_SIZE_T.
|
inline |
Get the length of the triangle's perimeter.
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Side().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Area().
|
inline |
Set one vertex of the triangle.
Keep in mind that the triangle normal is determined by the order of these vertices. Search the internet for "triangle winding" for more information.
[in] | _index | Index of the point to set. _index is clamped to the range [0,2]. |
[in] | _pt | Value of the point to set. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::clamp().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Triangle3().
|
inline |
Set all vertices of the triangle.
Keep in mind that the triangle normal is determined by the order of these vertices. Search the internet for "triangle winding" for more information.
[in] | _pt1 | First point that defines the triangle. |
[in] | _pt2 | Second point that defines the triangle. |
[in] | _pt3 | Third point that defines the triangle. |
|
inline |
Get a line segment for one side of the triangle.
[in] | _index | Index of the side to retrieve, where 0 == Line3(pt1, pt2), 1 == Line3(pt2, pt3), 2 == Line3(pt3, pt1). _index is clamped to the range [0,2]. |
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Area(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Contains(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Perimeter(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Valid().
|
inline |
Get whether this triangle is valid, based on triangle inequality: the sum of the lengths of any two sides must be greater than the length of the remaining side.
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle3< T >::Side().