Murl Engine API  Version 2018.3
Murl::Math::Ray< DataType > Class Template Reference

A ray class. More...

#include <murl_math_ray.h>

Detailed Description

template<class DataType>
class Murl::Math::Ray< DataType >

A ray class.

Public Types

typedef DataType ValueType
 The template parameter value type. More...
 

Public Member Functions

 Ray ()
 The default constructor. More...
 
 Ray (const Vector< DataType > &origin, const Vector< DataType > &direction)
 Constructor taking origin and direction vectors. More...
 
template<class DataType2 >
 Ray (const Ray< DataType2 > &other)
 The copy constructor using a ray of different type. More...
 
void Set (const Ray &other)
 Copy the content of a source ray to the ray instance. More...
 
void Set (const Vector< DataType > &origin, const Vector< DataType > &direction)
 Set a ray from given origin and direction vectors. More...
 
void SetOrigin (const Vector< DataType > &origin)
 Set the ray origin. More...
 
const Vector< DataType > & GetOrigin () const
 Get the ray origin. More...
 
void SetDirection (const Vector< DataType > &direction)
 Set the ray direction. More...
 
const Vector< DataType > & GetDirection () const
 Get the ray direction. More...
 
Bool IsIntersecting (const Sphere< DataType > &sphere, DataType *lambda=0) const
 Check if the ray is intersecting a given sphere. More...
 
Bool IsIntersecting (const Box< DataType > &box, DataType *lambda=0) const
 Check if the ray is intersecting a given box. More...
 

Protected Attributes

Vector< DataType > mOrigin
 The origin of the ray. More...
 
Vector< DataType > mDirection
 The direction of the ray. More...
 

Member Typedef Documentation

◆ ValueType

template<class DataType >
typedef DataType Murl::Math::Ray< DataType >::ValueType

The template parameter value type.

Constructor & Destructor Documentation

◆ Ray() [1/3]

template<class DataType >
Murl::Math::Ray< DataType >::Ray ( )
inline

The default constructor.

This creates a ray starting at (0/0/0) and pointing towards the positive Z axis.

◆ Ray() [2/3]

template<class DataType >
Murl::Math::Ray< DataType >::Ray ( const Vector< DataType > &  origin,
const Vector< DataType > &  direction 
)
inline

Constructor taking origin and direction vectors.

Parameters
originThe ray origin.
directionThe ray direction.

◆ Ray() [3/3]

template<class DataType >
template<class DataType2 >
Murl::Math::Ray< DataType >::Ray ( const Ray< DataType2 > &  other)
inline

The copy constructor using a ray of different type.

Parameters
otherThe ray to copy.

Member Function Documentation

◆ Set() [1/2]

template<class DataType >
void Murl::Math::Ray< DataType >::Set ( const Ray< DataType > &  other)
inline

Copy the content of a source ray to the ray instance.

Parameters
otherThe ray to copy from.

◆ Set() [2/2]

template<class DataType >
void Murl::Math::Ray< DataType >::Set ( const Vector< DataType > &  origin,
const Vector< DataType > &  direction 
)
inline

Set a ray from given origin and direction vectors.

Parameters
originThe ray origin.
directionThe ray direction.

◆ SetOrigin()

template<class DataType >
void Murl::Math::Ray< DataType >::SetOrigin ( const Vector< DataType > &  origin)
inline

Set the ray origin.

Parameters
originThe ray origin.

◆ GetOrigin()

template<class DataType >
const Vector<DataType>& Murl::Math::Ray< DataType >::GetOrigin ( ) const
inline

Get the ray origin.

Returns
The ray origin.

◆ SetDirection()

template<class DataType >
void Murl::Math::Ray< DataType >::SetDirection ( const Vector< DataType > &  direction)
inline

Set the ray direction.

Parameters
directionThe ray direction.

◆ GetDirection()

template<class DataType >
const Vector<DataType>& Murl::Math::Ray< DataType >::GetDirection ( ) const
inline

Get the ray direction.

Returns
The ray direction.

◆ IsIntersecting() [1/2]

template<class DataType >
Bool Murl::Math::Ray< DataType >::IsIntersecting ( const Sphere< DataType > &  sphere,
DataType *  lambda = 0 
) const
inline

Check if the ray is intersecting a given sphere.

Parameters
sphereThe sphere to check.
lambdaAn optional pointer to a variable receiving the lambda value of the intersection, i.e. the distance between the intersection point and the ray origin along the ray direction.
Returns
true if the ray is intersecting the sphere.

◆ IsIntersecting() [2/2]

template<class DataType >
Bool Murl::Math::Ray< DataType >::IsIntersecting ( const Box< DataType > &  box,
DataType *  lambda = 0 
) const
inline

Check if the ray is intersecting a given box.

Parameters
boxThe box to check.
lambdaAn optional pointer to a variable receiving the lambda value of the intersection, i.e. the distance between the intersection point and the ray origin along the ray direction.
Returns
true if the ray is intersecting the box.

Member Data Documentation

◆ mOrigin

template<class DataType >
Vector<DataType> Murl::Math::Ray< DataType >::mOrigin
protected

The origin of the ray.

◆ mDirection

template<class DataType >
Vector<DataType> Murl::Math::Ray< DataType >::mDirection
protected

The direction of the ray.


The documentation for this class was generated from the following files: