GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::Triangle< N, T > Struct Template Reference

Generic triangle shape in N-dimensional space. More...

#include <GREM/core/geometry.hpp>

Public Types

using Component = T
 Scalar coordinate component type.

Public Member Functions

template<typename U>
GREM_ALWAYS_INLINE constexpr operator Triangle< N, U > () const noexcept
 Convert this triangle to an equivalent triangle of another scalar type.
bool operator== (const Triangle &other) const =default
 Compare this triangle to another for equality.
constexpr bool contains (const Point< N, T > &point) const noexcept
 Check if a given point is contained within the extents of this triangle.
constexpr bool intersects (const Ray< N, T > &ray) const noexcept
 Check if this triangle intersects a given ray.
constexpr RaycastResult< N, T > raycast (const Ray< N, T > &ray) const noexcept
 Find the closest intersection of this triangle with a given ray.
constexpr Box< N, T > getBoundingBox () const noexcept
 Get the axis-aligned bounding box of the triangle.

Public Attributes

Point< N, T > pointA
 First point of the triangle.
Point< N, T > pointB
 Second point of the triangle.
Point< N, T > pointC
 Third point of the triangle.

Static Public Attributes

static constexpr size_t RANK = N
 Number of dimensions of the vector space.

Detailed Description

template<size_t N, typename T>
struct grem::Triangle< N, T >

Generic triangle shape in N-dimensional space.

Template Parameters
Nnumber of vector dimensions.
Tscalar coordinate component type.

Member Typedef Documentation

◆ Component

template<size_t N, typename T>
using grem::Triangle< N, T >::Component = T

Scalar coordinate component type.

Member Function Documentation

◆ operator Triangle< N, U >()

template<size_t N, typename T>
template<typename U>
GREM_ALWAYS_INLINE constexpr grem::Triangle< N, T >::operator Triangle< N, U > ( ) const
inlineexplicitconstexprnoexcept

Convert this triangle to an equivalent triangle of another scalar type.

Returns
the converted triangle.

◆ operator==()

template<size_t N, typename T>
bool grem::Triangle< N, T >::operator== ( const Triangle< N, T > & other) const
nodiscarddefault

Compare this triangle to another for equality.

Parameters
otherthe triangle to compare this triangle to.
Returns
true if the triangles are equal, false otherwise.

◆ contains()

template<size_t N, typename T>
bool grem::Triangle< N, T >::contains ( const Point< N, T > & point) const
inlinenodiscardconstexprnoexcept

Check if a given point is contained within the extents of this triangle.

Parameters
pointpoint to check.
Returns
true if the triangle contains the given point, false otherwise.

◆ intersects()

template<size_t N, typename T>
bool grem::Triangle< N, T >::intersects ( const Ray< N, T > & ray) const
inlinenodiscardconstexprnoexcept

Check if this triangle intersects a given ray.

Parameters
rayray to check.
Returns
true if an intersection was found, false otherwise.

◆ raycast()

template<size_t N, typename T>
RaycastResult< N, T > grem::Triangle< N, T >::raycast ( const Ray< N, T > & ray) const
inlinenodiscardconstexprnoexcept

Find the closest intersection of this triangle with a given ray.

Parameters
rayray to check.
Returns
the result of the raycast.

◆ getBoundingBox()

template<size_t N, typename T>
Box< N, T > grem::Triangle< N, T >::getBoundingBox ( ) const
inlinenodiscardconstexprnoexcept

Get the axis-aligned bounding box of the triangle.

Returns
an axis-aligned box that contains the entire triangle.

Member Data Documentation

◆ RANK

template<size_t N, typename T>
size_t grem::Triangle< N, T >::RANK = N
staticconstexpr

Number of dimensions of the vector space.

◆ pointA

template<size_t N, typename T>
Point<N, T> grem::Triangle< N, T >::pointA

First point of the triangle.

◆ pointB

template<size_t N, typename T>
Point<N, T> grem::Triangle< N, T >::pointB

Second point of the triangle.

◆ pointC

template<size_t N, typename T>
Point<N, T> grem::Triangle< N, T >::pointC

Third point of the triangle.


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