Triangle class and related functions. More...
#include <ignition/math/Triangle.hh>
Public Member Functions | |
Triangle ()=default | |
Default constructor. More... | |
Triangle (const math::Vector2< T > &_pt1, const math::Vector2< T > &_pt2, const math::Vector2< T > &_pt3) | |
Constructor. More... | |
double | Area () const |
Get the area of this triangle. More... | |
bool | Contains (const Line2< T > &_line) const |
Check if this triangle completely contains the given line segment. More... | |
bool | Contains (const math::Vector2< T > &_pt) const |
Get whether this triangle contains the given point. More... | |
bool | Intersects (const Line2< T > &_line, math::Vector2< T > &_ipt1, math::Vector2< T > &_ipt2) const |
Get whether the given line intersects this triangle. More... | |
math::Vector2< T > | operator[] (size_t _index) const |
Get one of points that define the triangle. More... | |
T | Perimeter () const |
Get the length of the triangle's perimeter. More... | |
void | Set (unsigned int _index, const math::Vector2< T > &_pt) |
Set one vertex of the triangle. More... | |
void | Set (const math::Vector2< T > &_pt1, const math::Vector2< T > &_pt2, const math::Vector2< T > &_pt3) |
Set all vertices of the triangle. More... | |
Line2< T > | Side (unsigned int _index) const |
Get a line segment for one side of the triangle. More... | |
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. More... | |
Triangle class and related functions.
|
default |
Default constructor.
|
inline |
Constructor.
[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::Triangle< T >::Set().
|
inline |
Get the area of this triangle.
References ignition::math::Triangle< T >::Perimeter(), and ignition::math::Triangle< T >::Side().
|
inline |
Check if this triangle completely contains the given line segment.
[in] | _line | Line to check. |
Referenced by ignition::math::Triangle< T >::Intersects().
|
inline |
Get whether this triangle contains the given point.
[in] | _pt | Point to check. |
References ignition::math::Vector2< T >::Dot().
|
inline |
Get whether the given line intersects this triangle.
[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. |
[out] | _ipt2 | Return value of the second intersection point, only valid if the return value of the function is true. |
References ignition::math::Triangle< T >::Contains(), and ignition::math::Line2< T >::Intersect().
|
inline |
Get one of points that define the triangle.
[in] | _index | 0, 1, or 2. |
IndexException | if _index is > 2. |
|
inline |
Get the length of the triangle's perimeter.
References ignition::math::Triangle< T >::Side().
Referenced by ignition::math::Triangle< T >::Area().
|
inline |
Set one vertex of the triangle.
[in] | _index | Index of the point to set. |
[in] | _pt | Value of the point to set. |
IndexException | if _index is > 2. |
Referenced by ignition::math::Triangle< T >::Triangle().
|
inline |
Set all vertices of the triangle.
[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 retreive, where 0 == Line2(pt1, pt2), 1 == Line2(pt2, pt3), 2 == Line2(pt3, pt1) |
IndexException | if _index is > 2. |
Referenced by ignition::math::Triangle< T >::Area(), ignition::math::Triangle< T >::Perimeter(), and ignition::math::Triangle< 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::Triangle< T >::Side().