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

Description of a ray. 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::Ray< N, Scalar > in (OtherUnitT unit) const noexcept
 Convert this physical ray to a unitless ray given a desired unit.

Static Public Member Functions

static constexpr Optional< Ray > between (Position< N > origin, Position< N > destination)
 Create a ray between two points.
template<typename T>
static GREM_ALWAYS_INLINE constexpr Ray reinterpret (const grem::Ray< N, T > &ray) noexcept
 Reinterpret a unitless ray as a physical ray in default units.

Public Attributes

Position< N > origin
 Starting position of the ray.
Direction< N > direction
 Unit vector pointing in the direction of the ray.
Distance maxDistance = Distance::MAX
 Maximum hit distance of the ray.
Scale< N > directionInverse = Scale<N>{Scalar{1}} / direction
 Component-wise reciprocal of the ray direction.

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::Ray< N >

Description of a ray.

Template Parameters
Nnumber of dimensions of the world space (must be 2 or 3).

Member Typedef Documentation

◆ Unit

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

Unit type.

◆ DimensionType

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

Unit dimension type.

◆ MagnitudeType

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

Unit magnitude type.

Member Function Documentation

◆ between()

template<size_t N>
constexpr Optional< Ray > grem::physics::Ray< N >::between ( Position< N > origin,
Position< N > destination )
inlinestaticnodiscardconstexpr

Create a ray between two points.

Parameters
originstarting point of the ray.
destinationend point of the ray.
Returns
a ray from the specified origin to the specified destination, or an empty optional if the distance between the points is too small to calculate a unit direction vector.

◆ reinterpret()

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

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

Parameters
rayray to reinterpret.
Returns
the corresponding physical ray.

◆ in()

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

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

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

Member Data Documentation

◆ UNIT

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

Unit.

◆ DIMENSION

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

Unit dimension.

◆ MAGNITUDE

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

Unit magnitude.

◆ origin

template<size_t N>
Position<N> grem::physics::Ray< N >::origin

Starting position of the ray.

◆ direction

template<size_t N>
Direction<N> grem::physics::Ray< N >::direction

Unit vector pointing in the direction of the ray.

Warning
Must be a unit vector.

◆ maxDistance

template<size_t N>
Distance grem::physics::Ray< N >::maxDistance = Distance::MAX

Maximum hit distance of the ray.

Warning
Must be non-negative.

◆ directionInverse

template<size_t N>
Scale<N> grem::physics::Ray< N >::directionInverse = Scale<N>{Scalar{1}} / direction

Component-wise reciprocal of the ray direction.

Warning
Must be equal to the reciprocal of direction.

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