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

Description of a triangle in world space. More...

#include <GREM/physics/Shape.hpp>

Public Types

using Unit = typename Position<N>::Unit
 Unit type.
using DimensionType = typename Unit::DimensionType
 Unit dimension type.
using MagnitudeType = typename Unit::MagnitudeType
 Unit magnitude type.

Public Member Functions

template<typename OtherUnitT>
requires (OtherUnitT::DIMENSION == LENGTH)
GREM_ALWAYS_INLINE constexpr grem::Triangle< N, Scalar > in (OtherUnitT unit) const noexcept
 Convert this physical triangle to a unitless triangle given a desired unit.
bool operator== (const Triangle &other) const =default
 Compare this triangle to another for equality.
GREM_ALWAYS_INLINE constexpr bool contains (const Position< N > &point) const noexcept
 Check if a given point is contained within the extents of this triangle.
GREM_ALWAYS_INLINE constexpr bool intersects (const Ray< N > &ray) const noexcept
 Check if this triangle intersects a given ray.
GREM_ALWAYS_INLINE constexpr RaycastResult< N > raycast (const Ray< N > &ray) const noexcept
 Find the closest intersection of this triangle with a given ray.
GREM_ALWAYS_INLINE constexpr Box< N > getBoundingBox () const noexcept
 Get the axis-aligned bounding box of the triangle.

Static Public Member Functions

template<typename T>
static GREM_ALWAYS_INLINE constexpr Triangle reinterpret (const grem::Triangle< N, T > &triangle) noexcept
 Reinterpret a unitless triangle as a physical triangle in default units.

Public Attributes

Position< N > pointA
 First point of the triangle.
Position< N > pointB
 Second point of the triangle.
Position< N > pointC
 Third point of the triangle.

Static Public Attributes

static constexpr Unit UNIT {}
 Unit.
static constexpr DimensionType DIMENSION {}
 Unit dimension.
static constexpr MagnitudeType MAGNITUDE {}
 Unit magnitude.

Detailed Description

template<size_t N>
struct grem::physics::Triangle< N >

Description of a triangle in world space.

Member Typedef Documentation

◆ Unit

template<size_t N>
using grem::physics::Triangle< N >::Unit = typename Position<N>::Unit

Unit type.

◆ DimensionType

template<size_t N>
using grem::physics::Triangle< N >::DimensionType = typename Unit::DimensionType

Unit dimension type.

◆ MagnitudeType

template<size_t N>
using grem::physics::Triangle< N >::MagnitudeType = typename Unit::MagnitudeType

Unit magnitude type.

Member Function Documentation

◆ reinterpret()

template<size_t N>
template<typename T>
GREM_ALWAYS_INLINE constexpr Triangle grem::physics::Triangle< N >::reinterpret ( const grem::Triangle< N, T > & triangle)
inlinestaticnodiscardconstexprnoexcept

Reinterpret a unitless triangle as a physical triangle in default units.

Parameters
triangletriangle to reinterpret.
Returns
the corresponding physical triangle.

◆ in()

template<size_t N>
template<typename OtherUnitT>
requires (OtherUnitT::DIMENSION == LENGTH)
GREM_ALWAYS_INLINE constexpr grem::Triangle< N, Scalar > grem::physics::Triangle< N >::in ( OtherUnitT unit) const
inlinenodiscardconstexprnoexcept

Convert this physical triangle to a unitless triangle given a desired unit.

Parameters
unitunit to get the triangle in.
Returns
the corresponding triangle in the given unit.

◆ operator==()

template<size_t N>
bool grem::physics::Triangle< N >::operator== ( const Triangle< N > & 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>
GREM_ALWAYS_INLINE constexpr bool grem::physics::Triangle< N >::contains ( const Position< N > & 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>
GREM_ALWAYS_INLINE constexpr bool grem::physics::Triangle< N >::intersects ( const Ray< N > & 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>
GREM_ALWAYS_INLINE constexpr RaycastResult< N > grem::physics::Triangle< N >::raycast ( const Ray< N > & 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>
GREM_ALWAYS_INLINE constexpr Box< N > grem::physics::Triangle< N >::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

◆ UNIT

template<size_t N>
Unit grem::physics::Triangle< N >::UNIT {}
staticconstexpr

Unit.

◆ DIMENSION

template<size_t N>
DimensionType grem::physics::Triangle< N >::DIMENSION {}
staticconstexpr

Unit dimension.

◆ MAGNITUDE

template<size_t N>
MagnitudeType grem::physics::Triangle< N >::MAGNITUDE {}
staticconstexpr

Unit magnitude.

◆ pointA

template<size_t N>
Position<N> grem::physics::Triangle< N >::pointA

First point of the triangle.

◆ pointB

template<size_t N>
Position<N> grem::physics::Triangle< N >::pointB

Second point of the triangle.

◆ pointC

template<size_t N>
Position<N> grem::physics::Triangle< N >::pointC

Third point of the triangle.


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