UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
ufo::Triangle< Dim, T > Struct Template Reference

Triangle in Dim-dimensional space. More...

#include <lib/geometry/include/ufo/geometry/triangle.hpp>

Public Types

using value_type = T
 

Public Member Functions

constexpr Triangle () noexcept=default
 Default constructor.
 
constexpr Triangle (Triangle const &) noexcept=default
 Copy constructor.
 
template<std::convertible_to< T > U>
constexpr Triangle (Triangle< Dim, U > const &other) noexcept
 Converting constructor from a triangle with a different scalar type.
 
constexpr Triangle (Vec< Dim, T > point_1, Vec< Dim, T > point_2, Vec< Dim, T > point_3) noexcept
 Constructs a triangle from three points.
 
constexpr AABB< Dim, T > aabb () const noexcept
 Returns the AABB of the triangle.
 
constexpr T area () const noexcept
 Returns the area of the triangle.
 
constexpr Vec< Dim, T > center () const noexcept
 Returns the centroid (arithmetic mean) of the triangle.
 
constexpr T diameter () const noexcept
 Returns the diameter of the triangle.
 
constexpr bool isDegenerate (T eps=std::numeric_limits< T >::epsilon()) const noexcept
 Returns true if the triangle is degenerate.
 
constexpr Vec< 3, T > normal () const noexcept
 Returns the surface unit normal of the triangle.
 
bool operator== (Triangle const &) const =default
 Equality operator.
 
constexpr auto & operator[] (this auto &self, std::size_t pos) noexcept
 Returns the vertex at position pos.
 
constexpr T volume () const noexcept
 Returns the volume of the triangle.
 

Static Public Member Functions

static constexpr std::size_t dimension () noexcept
 Returns the dimensionality of the triangle.
 

Public Attributes

std::array< Vec< Dim, T >, 3 > points
 The vertices of the triangle.
 

Detailed Description

template<std::size_t Dim = 3, std::floating_point T = float>
struct ufo::Triangle< Dim, T >

Triangle in Dim-dimensional space.

Template Parameters
DimThe dimensionality of the space (default: 3).
TThe numeric type (default: float), must be a floating-point type.

Represents a triangle defined by three points.

Definition at line 70 of file triangle.hpp.

Member Typedef Documentation

◆ value_type

template<std::size_t Dim = 3, std::floating_point T = float>
using ufo::Triangle< Dim, T >::value_type = T

Definition at line 71 of file triangle.hpp.

Constructor & Destructor Documentation

◆ Triangle() [1/2]

template<std::size_t Dim = 3, std::floating_point T = float>
constexpr ufo::Triangle< Dim, T >::Triangle ( Vec< Dim, T >  point_1,
Vec< Dim, T >  point_2,
Vec< Dim, T >  point_3 
)
inlineconstexprnoexcept

Constructs a triangle from three points.

Parameters
[in]point_1The first point.
[in]point_2The second point.
[in]point_3The third point.

Definition at line 94 of file triangle.hpp.

◆ Triangle() [2/2]

template<std::size_t Dim = 3, std::floating_point T = float>
template<std::convertible_to< T > U>
constexpr ufo::Triangle< Dim, T >::Triangle ( Triangle< Dim, U > const &  other)
inlineexplicitconstexprnoexcept

Converting constructor from a triangle with a different scalar type.

Template Parameters
UThe scalar type of the other triangle.
Parameters
[in]otherThe other triangle.

Definition at line 106 of file triangle.hpp.

Member Function Documentation

◆ aabb()

template<std::size_t Dim = 3, std::floating_point T = float>
constexpr AABB< Dim, T > ufo::Triangle< Dim, T >::aabb ( ) const
inlineconstexprnoexcept

Returns the AABB of the triangle.

Returns
The AABB.

Definition at line 156 of file triangle.hpp.

◆ area()

template<std::size_t Dim = 3, std::floating_point T = float>
constexpr T ufo::Triangle< Dim, T >::area ( ) const
inlineconstexprnoexcept

Returns the area of the triangle.

Returns
The area of the triangle.

Uses the general formula for a triangle in N-dimensional space.

Definition at line 142 of file triangle.hpp.

◆ center()

template<std::size_t Dim = 3, std::floating_point T = float>
constexpr Vec< Dim, T > ufo::Triangle< Dim, T >::center ( ) const
inlineconstexprnoexcept

Returns the centroid (arithmetic mean) of the triangle.

Returns
The centroid of the triangle.

Definition at line 131 of file triangle.hpp.

◆ diameter()

template<std::size_t Dim = 3, std::floating_point T = float>
constexpr T ufo::Triangle< Dim, T >::diameter ( ) const
inlineconstexprnoexcept

Returns the diameter of the triangle.

Returns
The diameter (maximum edge length).

Definition at line 197 of file triangle.hpp.

◆ dimension()

template<std::size_t Dim = 3, std::floating_point T = float>
static constexpr std::size_t ufo::Triangle< Dim, T >::dimension ( )
inlinestaticconstexprnoexcept

Returns the dimensionality of the triangle.

Returns
The dimensionality.

Definition at line 115 of file triangle.hpp.

◆ isDegenerate()

template<std::size_t Dim = 3, std::floating_point T = float>
constexpr bool ufo::Triangle< Dim, T >::isDegenerate ( eps = std::numeric_limits<T>::epsilon()) const
inlineconstexprnoexcept

Returns true if the triangle is degenerate.

Parameters
[in]epsThe epsilon value for the check.
Returns
True if the triangle is degenerate.

A triangle is degenerate if its area is effectively zero.

Definition at line 181 of file triangle.hpp.

◆ normal()

template<std::size_t Dim = 3, std::floating_point T = float>
constexpr Vec< 3, T > ufo::Triangle< Dim, T >::normal ( ) const
inlineconstexprnoexcept

Returns the surface unit normal of the triangle.

Returns
The surface unit normal.

This method is only available for 3D triangles.

Definition at line 168 of file triangle.hpp.

◆ operator[]()

template<std::size_t Dim = 3, std::floating_point T = float>
constexpr auto & ufo::Triangle< Dim, T >::operator[] ( this auto &  self,
std::size_t  pos 
)
inlineconstexprnoexcept

Returns the vertex at position pos.

Parameters
[in]posThe position of the vertex [0..2].
Returns
A (const) reference to the vertex.

Definition at line 122 of file triangle.hpp.

◆ volume()

template<std::size_t Dim = 3, std::floating_point T = float>
constexpr T ufo::Triangle< Dim, T >::volume ( ) const
inlineconstexprnoexcept

Returns the volume of the triangle.

Returns
The volume (always 0).

Definition at line 191 of file triangle.hpp.

Member Data Documentation

◆ points

template<std::size_t Dim = 3, std::floating_point T = float>
std::array<Vec<Dim, T>, 3> ufo::Triangle< Dim, T >::points

The vertices of the triangle.

Definition at line 76 of file triangle.hpp.


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