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

Generic ray with an origin and direction in N-dimensional space. More...

#include <GREM/core/geometry.hpp>

Public Types

using Component = T
 Scalar coordinate component type.

Static Public Member Functions

static constexpr Optional< Ray > between (Point< N, T > origin, Point< N, T > destination)
 Create a ray between two points.

Public Attributes

Point< N, T > origin
 Starting position of the ray.
vec< N, T > direction
 Unit vector pointing in the direction of the ray.
T maxDistance = Limits<T>::MAX
 Maximum hit distance of the ray.
vec< N, T > directionInverse = vec<N, T>{T{1}} / direction
 Component-wise reciprocal of the ray direction.

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

Generic ray with an origin and direction 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::Ray< N, T >::Component = T

Scalar coordinate component type.

Member Function Documentation

◆ between()

template<size_t N, typename T>
constexpr Optional< Ray > grem::Ray< N, T >::between ( Point< N, T > origin,
Point< N, T > 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.

Member Data Documentation

◆ RANK

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

Number of dimensions of the vector space.

◆ origin

template<size_t N, typename T>
Point<N, T> grem::Ray< N, T >::origin

Starting position of the ray.

◆ direction

template<size_t N, typename T>
vec<N, T> grem::Ray< N, T >::direction

Unit vector pointing in the direction of the ray.

Warning
Must be a unit vector.

◆ maxDistance

template<size_t N, typename T>
T grem::Ray< N, T >::maxDistance = Limits<T>::MAX

Maximum hit distance of the ray.

Warning
Must be non-negative.

◆ directionInverse

template<size_t N, typename T>
vec<N, T> grem::Ray< N, T >::directionInverse = vec<N, T>{T{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: