CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Math::TRay< T > Struct Template Reference

A ray in 3D space represented with an origin and direction. More...

#include <CeresEngine/Math/Geometry.hpp>

Public Member Functions

constexpr TRay ()=default
 Creates a new default ray.
 
constexpr TRay (const TVector3< T > &origin, const TVector3< T > &direction)
 Creates a new ray that starts from the given origin and moves in the given direction.
 
constexpr TVector3< T > getPoint (T t) const
 Gets the position of a point t units along the ray.
 
void transform (const TMatrix4< T > &matrix)
 Transforms the ray by the given matrix.
 
void transform (const TTransform< T > &aTransform)
 Transforms the ray by the given matrix.
 
TRayIntersection< T > intersects (const TPlane< T > &p) const
 Ray/plane intersection, returns boolean result and distance to intersection point.
 
TRayIntersection< T > intersects (const TSphere< T > &s) const
 Ray/sphere intersection, returns boolean result and distance to nearest intersection point.
 
TRayIntersection< T > intersects (const TAABox< T > &box) const
 Ray/axis aligned box intersection, returns boolean result and distance to nearest intersection point.
 
TRayIntersection< T > intersects (const TVector3< T > &a, const TVector3< T > &b, const TVector3< T > &c, const TVector3< T > &normal, bool positiveSide=true, bool negativeSide=true) const
 Ray/triangle intersection, returns boolean result and distance to intersection point.
 
constexpr TVector3< T > operator[] (T t) const
 Gets the position of a point t units along the ray.
 

Public Attributes

TVector3< T > origin = TVector3<T>(T(0.0))
 The ray origin position.
 
TVector3< T > direction = TVector3<T>(T(0.0), T(0.0), T(1.0))
 The ray direction vector.
 

Friends

TRay< T > operator* (const TMatrix4< T > &lhs, TRay< T > rhs)
 Transforms the ray by the given matrix.
 
TRay< T > operator* (const TTransform< T > &lhs, TRay< T > rhs)
 Transforms the ray by the given transform.
 

Detailed Description

template<typename T>
struct Math::TRay< T >

A ray in 3D space represented with an origin and direction.

Constructor & Destructor Documentation

◆ TRay() [1/2]

template<typename T >
constexpr Math::TRay< T >::TRay ( )
constexprdefault

Creates a new default ray.

◆ TRay() [2/2]

template<typename T >
constexpr Math::TRay< T >::TRay ( const TVector3< T > &  origin,
const TVector3< T > &  direction 
)
inlineconstexpr

Creates a new ray that starts from the given origin and moves in the given direction.

Parameters
originThe ray origin position
directionThe ray direction vector

Member Function Documentation

◆ getPoint()

template<typename T >
constexpr TVector3< T > Math::TRay< T >::getPoint ( t) const
inlineconstexpr

Gets the position of a point t units along the ray.

◆ intersects() [1/4]

template<typename T >
TRayIntersection< T > Math::TRay< T >::intersects ( const TAABox< T > &  box) const

Ray/axis aligned box intersection, returns boolean result and distance to nearest intersection point.

◆ intersects() [2/4]

template<typename T >
TRayIntersection< T > Math::TRay< T >::intersects ( const TPlane< T > &  p) const

Ray/plane intersection, returns boolean result and distance to intersection point.

◆ intersects() [3/4]

template<typename T >
TRayIntersection< T > Math::TRay< T >::intersects ( const TSphere< T > &  s) const

Ray/sphere intersection, returns boolean result and distance to nearest intersection point.

◆ intersects() [4/4]

template<typename T >
TRayIntersection< T > Math::TRay< T >::intersects ( const TVector3< T > &  a,
const TVector3< T > &  b,
const TVector3< T > &  c,
const TVector3< T > &  normal,
bool  positiveSide = true,
bool  negativeSide = true 
) const

Ray/triangle intersection, returns boolean result and distance to intersection point.

Parameters
aTriangle first vertex.
bTriangle second vertex.
cTriangle third vertex.
normalThe normal of the triangle. Doesn't need to be normalized.
positiveSideShould intersections with the positive side (the normal facing) count.
negativeSideShould intersections with the negative side (the opposite of normal facing) count.
Returns
Boolean result if intersection happened and distance to intersection point.

◆ operator[]()

template<typename T >
constexpr TVector3< T > Math::TRay< T >::operator[] ( t) const
inlineconstexpr

Gets the position of a point t units along the ray.

◆ transform() [1/2]

template<typename T >
void Math::TRay< T >::transform ( const TMatrix4< T > &  matrix)

Transforms the ray by the given matrix.

◆ transform() [2/2]

template<typename T >
void Math::TRay< T >::transform ( const TTransform< T > &  aTransform)
inline

Transforms the ray by the given matrix.

Friends And Related Symbol Documentation

◆ operator* [1/2]

template<typename T >
TRay< T > operator* ( const TMatrix4< T > &  lhs,
TRay< T >  rhs 
)
friend

Transforms the ray by the given matrix.

Parameters
lhsThe transformation to be applied
rhsThe ray to apply the transformation for
Returns
The transformed ray

◆ operator* [2/2]

template<typename T >
TRay< T > operator* ( const TTransform< T > &  lhs,
TRay< T >  rhs 
)
friend

Transforms the ray by the given transform.

Parameters
lhsThe transformation to be applied
rhsThe ray to apply the transformation for
Returns
The transformed ray

Member Data Documentation

◆ direction

template<typename T >
TVector3<T> Math::TRay< T >::direction = TVector3<T>(T(0.0), T(0.0), T(1.0))

The ray direction vector.

◆ origin

template<typename T >
TVector3<T> Math::TRay< T >::origin = TVector3<T>(T(0.0))

The ray origin position.


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