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

Triangle class and related functions. More...

#include <ignition/math/Triangle.hh>

Public Member Functions

 Triangle ()=default
 Default constructor.
 Triangle (const math::Vector2< T > &_pt1, const math::Vector2< T > &_pt2, const math::Vector2< T > &_pt3)
 Constructor.
double Area () const
 Get the area of this triangle.
bool Contains (const Line2< T > &_line) const
 Check if this triangle completely contains the given line segment.
bool Contains (const math::Vector2< T > &_pt) const
 Get whether this triangle contains the given point.
bool Intersects (const Line2< T > &_line, math::Vector2< T > &_ipt1, math::Vector2< T > &_ipt2) const
 Get whether the given line intersects this triangle.
math::Vector2< T > operator[] (const size_t _index) const
 Get one of points that define the triangle.
Perimeter () const
 Get the length of the triangle's perimeter.
void Set (const math::Vector2< T > &_pt1, const math::Vector2< T > &_pt2, const math::Vector2< T > &_pt3)
 Set all vertices of the triangle.
void Set (const unsigned int _index, const math::Vector2< T > &_pt)
 Set one vertex of the triangle.
Line2< 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.

Detailed Description

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

Triangle class and related functions.

Constructor & Destructor Documentation

◆ Triangle() [1/2]

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

Default constructor.

◆ Triangle() [2/2]

template<typename T>
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Triangle ( const math::Vector2< T > & _pt1,
const math::Vector2< T > & _pt2,
const math::Vector2< T > & _pt3 )
inline

Constructor.

Parameters
[in]_pt1First point that defines the triangle.
[in]_pt2Second point that defines the triangle.
[in]_pt3Third point that defines the triangle.

Member Function Documentation

◆ Area()

template<typename T>
double ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Area ( ) const
inline

Get the area of this triangle.

Returns
Triangle's area.

◆ Contains() [1/2]

template<typename T>
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Contains ( const Line2< T > & _line) const
inline

Check if this triangle completely contains the given line segment.

Parameters
[in]_lineLine to check.
Returns
True if the line's start and end points are both inside this triangle.

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< int >::Contains(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< int >::Intersects().

◆ Contains() [2/2]

template<typename T>
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Contains ( const math::Vector2< T > & _pt) const
inline

Get whether this triangle contains the given point.

Parameters
[in]_ptPoint to check.
Returns
True if the point is inside or on the triangle.

◆ Intersects()

template<typename T>
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Intersects ( const Line2< T > & _line,
math::Vector2< T > & _ipt1,
math::Vector2< T > & _ipt2 ) const
inline

Get whether the given line intersects this triangle.

Parameters
[in]_lineLine to check.
[out]_ipt1Return value of the first intersection point, only valid if the return value of the function is true.
[out]_ipt2Return value of the second intersection point, only valid if the return value of the function is true.
Returns
True if the given line intersects this triangle.

◆ operator[]()

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

Get one of points that define the triangle.

Parameters
[in]_indexThe index, where 0 == first vertex, 1 == second vertex, and 2 == third vertex. The index is clamped to the range [0, 2]
Returns
The point specified by _index.

◆ Perimeter()

template<typename T>
T ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Perimeter ( ) const
inline

Get the length of the triangle's perimeter.

Returns
Sum of the triangle's line segments.

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< int >::Area().

◆ Set() [1/2]

template<typename T>
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Set ( const math::Vector2< T > & _pt1,
const math::Vector2< T > & _pt2,
const math::Vector2< T > & _pt3 )
inline

Set all vertices of the triangle.

Parameters
[in]_pt1First point that defines the triangle.
[in]_pt2Second point that defines the triangle.
[in]_pt3Third point that defines the triangle.

◆ Set() [2/2]

template<typename T>
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Set ( const unsigned int _index,
const math::Vector2< T > & _pt )
inline

Set one vertex of the triangle.

Parameters
[in]_indexIndex of the point to set, where 0 == first vertex, 1 == second vertex, and 2 == third vertex. The index is clamped to the range [0, 2].
[in]_ptValue of the point to set.

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< int >::Triangle().

◆ Side()

template<typename T>
Line2< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Side ( const unsigned int _index) const
inline

Get a line segment for one side of the triangle.

Parameters
[in]_indexIndex of the side to retreive, where 0 == Line2(pt1, pt2), 1 == Line2(pt2, pt3), 2 == Line2(pt3, pt1) The index is clamped to the range [0, 2]
Returns
Line segment of the requested side.

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< int >::Area(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< int >::Perimeter(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< int >::Valid().

◆ Valid()

template<typename T>
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Valid ( ) const
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.

Returns
True if the triangle inequality holds

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