utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
utility::graphic::Ray< RayComponentType > Class Template Reference

Geometric ray with arithmetic component type and fixed dimension. More...

#include <headers/utility/graphic/ray.hpp>

Collaboration diagram for utility::graphic::Ray< RayComponentType >:

Public Member Functions

 Ray (void)
 Default constructor creating a ray at origin along the first axis.
 
 Ray (math::Vector< RayComponentType, 3 > origin, math::Vector< RayComponentType, 3 > direction)
 Construct ray from origin and direction.
 
 Ray (const Ray &other)
 Copy constructor.
 
 Ray (Ray &&other) noexcept
 Move constructor.
 
Rayoperator= (const Ray &other)
 Copy assignment operator.
 
Rayoperator= (Ray &&other) noexcept
 Move assignment operator.
 
void setOrigin (const math::Vector< RayComponentType, 3 > &origin)
 Set the ray origin.
 
void setOrigin (const Position< RayComponentType > &origin)
 Set the ray origin using a Position value.
 
math::Vector< RayComponentType, 3 > getOrigin () const
 Get the ray origin.
 
void setDirection (const math::Vector< RayComponentType, 3 > &direction)
 Set the ray direction.
 
math::Vector< RayComponentType, 3 > getDirection (void) const
 Get the ray direction.
 
const Position< RayComponentType > & origin (void) const noexcept
 Access the ray origin by const reference.
 
const math::Vector< RayComponentType, 3 > & direction (void) const noexcept
 Access the ray direction by const reference.
 
math::Vector< RayComponentType, 3 > normalizedDirection () const
 Get a normalized copy of the ray direction.
 
math::Vector< RayComponentType, 3 > pointAt (RayComponentType distanceParameter) const
 Evaluate a point on the ray at the provided parameter.
 
math::Vector< RayComponentType, 3 > at (RayComponentType distanceParameter) const
 Alias for pointAt to match common ray APIs.
 
void translate (const math::Vector< RayComponentType, 3 > &offset)
 Translate ray origin by the provided offset.
 
Ray translated (const math::Vector< RayComponentType, 3 > &offset) const
 Get translated ray copy.
 
bool operator== (const Ray &other) const
 Equality comparison.
 
bool operator!= (const Ray &other) const
 Inequality comparison.
 
template<typename RectanglePoseType >
bool intersectRectangle (const RectanglePoseType &rectanglePose, const math::Vector2F &rectangleSize) const
 Check for intersection with an axis-aligned rectangle plane.
 
utility::graphic::Mesh convertToMesh (float length, float radius, int segments, utility::graphic::Color32Bit color={ 255, 255, 255, 255 }) const
 Convert the ray into a mesh representation for visualization.
 

Static Protected Member Functions

static void validateDirection (const math::Vector< RayComponentType, 3 > &direction)
 Validate that a direction vector is non-zero.
 

Protected Attributes

Position< RayComponentType > _origin
 Origin point of the ray.
 
math::Vector< RayComponentType, 3 > _direction
 Direction vector of the ray (must be non-zero).
 

Detailed Description

template<CanBeRayComponent RayComponentType>
class utility::graphic::Ray< RayComponentType >

Geometric ray with arithmetic component type and fixed dimension.

Template Parameters
TypeArithmetic type for origin and direction components.
DimensionCompile-time dimension of the ray vectors.

Definition at line 60 of file ray.hpp.

Constructor & Destructor Documentation

◆ Ray() [1/4]

template<CanBeRayComponent RayComponentType>
utility::graphic::Ray< RayComponentType >::Ray ( void  )
inline

Default constructor creating a ray at origin along the first axis.

Definition at line 94 of file ray.hpp.

Here is the caller graph for this function:

◆ Ray() [2/4]

template<CanBeRayComponent RayComponentType>
utility::graphic::Ray< RayComponentType >::Ray ( math::Vector< RayComponentType, 3 >  origin,
math::Vector< RayComponentType, 3 >  direction 
)
inline

Construct ray from origin and direction.

Parameters
originOrigin point.
directionDirection vector (must be non-zero).
Exceptions
std::invalid_argumentif direction is the zero vector.

Definition at line 107 of file ray.hpp.

Here is the call graph for this function:

◆ Ray() [3/4]

template<CanBeRayComponent RayComponentType>
utility::graphic::Ray< RayComponentType >::Ray ( const Ray< RayComponentType > &  other)
inline

Copy constructor.

Parameters
otherThe ray to copy from.

Definition at line 119 of file ray.hpp.

◆ Ray() [4/4]

template<CanBeRayComponent RayComponentType>
utility::graphic::Ray< RayComponentType >::Ray ( Ray< RayComponentType > &&  other)
inlinenoexcept

Move constructor.

Parameters
otherThe ray to move from.

Definition at line 129 of file ray.hpp.

Member Function Documentation

◆ at()

template<CanBeRayComponent RayComponentType>
math::Vector< RayComponentType, 3 > utility::graphic::Ray< RayComponentType >::at ( RayComponentType  distanceParameter) const
inline

Alias for pointAt to match common ray APIs.

Parameters
distanceParameterParameter value measured along direction.
Returns
Point computed as origin + direction * parameter.

Definition at line 257 of file ray.hpp.

Here is the call graph for this function:

◆ convertToMesh()

template<CanBeRayComponent RayComponentType>
utility::graphic::Mesh utility::graphic::Ray< RayComponentType >::convertToMesh ( float  length,
float  radius,
int  segments,
utility::graphic::Color32Bit  color = { 255, 255, 255, 255 } 
) const
inline

Convert the ray into a mesh representation for visualization.

Parameters
lengthLength of the ray mesh.
radiusRadius of the ray mesh.
segmentsNumber of segments around the circumference.
colorColor of the mesh vertices.
Returns
Mesh representing the ray as a cylinder.

Definition at line 386 of file ray.hpp.

◆ direction()

template<CanBeRayComponent RayComponentType>
const math::Vector< RayComponentType, 3 > & utility::graphic::Ray< RayComponentType >::direction ( void  ) const
inlinenoexcept

Access the ray direction by const reference.

Returns
Const reference to direction.

Definition at line 226 of file ray.hpp.

Here is the caller graph for this function:

◆ getDirection()

template<CanBeRayComponent RayComponentType>
math::Vector< RayComponentType, 3 > utility::graphic::Ray< RayComponentType >::getDirection ( void  ) const
inline

Get the ray direction.

Returns
Direction vector.

Definition at line 208 of file ray.hpp.

Here is the caller graph for this function:

◆ getOrigin()

template<CanBeRayComponent RayComponentType>
math::Vector< RayComponentType, 3 > utility::graphic::Ray< RayComponentType >::getOrigin ( ) const
inline

Get the ray origin.

Returns
Origin vector.

Definition at line 188 of file ray.hpp.

Here is the caller graph for this function:

◆ intersectRectangle()

template<CanBeRayComponent RayComponentType>
template<typename RectanglePoseType >
bool utility::graphic::Ray< RayComponentType >::intersectRectangle ( const RectanglePoseType &  rectanglePose,
const math::Vector2F rectangleSize 
) const
inline

Check for intersection with an axis-aligned rectangle plane.

Parameters
rectanglePosePose-like object providing position and orientation accessors.
rectangleSizeSize of the rectangle (width, height).
Returns
True if the ray intersects the rectangle, false if it misses or is parallel. Note that rays originating inside the rectangle are considered intersecting. Rays parallel to the rectangle plane that lie in the plane are also considered intersecting, while those that do not lie in the plane are considered non-intersecting.

Definition at line 314 of file ray.hpp.

Here is the call graph for this function:

◆ normalizedDirection()

template<CanBeRayComponent RayComponentType>
math::Vector< RayComponentType, 3 > utility::graphic::Ray< RayComponentType >::normalizedDirection ( ) const
inline

Get a normalized copy of the ray direction.

Returns
Unit-length direction vector.

Definition at line 235 of file ray.hpp.

◆ operator!=()

template<CanBeRayComponent RayComponentType>
bool utility::graphic::Ray< RayComponentType >::operator!= ( const Ray< RayComponentType > &  other) const
inline

Inequality comparison.

Parameters
otherRay to compare with.
Returns
True when origin or direction differ.

Definition at line 296 of file ray.hpp.

◆ operator=() [1/2]

template<CanBeRayComponent RayComponentType>
Ray & utility::graphic::Ray< RayComponentType >::operator= ( const Ray< RayComponentType > &  other)
inline

Copy assignment operator.

Parameters
otherThe ray to copy from.
Returns
Reference to this ray.

Definition at line 140 of file ray.hpp.

◆ operator=() [2/2]

template<CanBeRayComponent RayComponentType>
Ray & utility::graphic::Ray< RayComponentType >::operator= ( Ray< RayComponentType > &&  other)
inlinenoexcept

Move assignment operator.

Parameters
otherThe ray to move from.
Returns
Reference to this ray.

Definition at line 154 of file ray.hpp.

◆ operator==()

template<CanBeRayComponent RayComponentType>
bool utility::graphic::Ray< RayComponentType >::operator== ( const Ray< RayComponentType > &  other) const
inline

Equality comparison.

Parameters
otherRay to compare with.
Returns
True when origin and direction are equal.

Definition at line 286 of file ray.hpp.

◆ origin()

template<CanBeRayComponent RayComponentType>
const Position< RayComponentType > & utility::graphic::Ray< RayComponentType >::origin ( void  ) const
inlinenoexcept

Access the ray origin by const reference.

Returns
Const reference to origin.

Definition at line 217 of file ray.hpp.

Here is the caller graph for this function:

◆ pointAt()

template<CanBeRayComponent RayComponentType>
math::Vector< RayComponentType, 3 > utility::graphic::Ray< RayComponentType >::pointAt ( RayComponentType  distanceParameter) const
inline

Evaluate a point on the ray at the provided parameter.

Parameters
distanceParameterParameter value measured along direction.
Returns
Point computed as origin + direction * parameter.

Definition at line 246 of file ray.hpp.

Here is the caller graph for this function:

◆ setDirection()

template<CanBeRayComponent RayComponentType>
void utility::graphic::Ray< RayComponentType >::setDirection ( const math::Vector< RayComponentType, 3 > &  direction)
inline

Set the ray direction.

Parameters
directionNew direction vector (must be non-zero).
Exceptions
std::invalid_argumentif direction is the zero vector.

Definition at line 198 of file ray.hpp.

Here is the call graph for this function:

◆ setOrigin() [1/2]

template<CanBeRayComponent RayComponentType>
void utility::graphic::Ray< RayComponentType >::setOrigin ( const math::Vector< RayComponentType, 3 > &  origin)
inline

Set the ray origin.

Parameters
originNew origin vector.

Definition at line 170 of file ray.hpp.

Here is the call graph for this function:

◆ setOrigin() [2/2]

template<CanBeRayComponent RayComponentType>
void utility::graphic::Ray< RayComponentType >::setOrigin ( const Position< RayComponentType > &  origin)
inline

Set the ray origin using a Position value.

Parameters
originNew origin position.

Definition at line 179 of file ray.hpp.

Here is the call graph for this function:

◆ translate()

template<CanBeRayComponent RayComponentType>
void utility::graphic::Ray< RayComponentType >::translate ( const math::Vector< RayComponentType, 3 > &  offset)
inline

Translate ray origin by the provided offset.

Parameters
offsetTranslation vector.

Definition at line 266 of file ray.hpp.

◆ translated()

template<CanBeRayComponent RayComponentType>
Ray utility::graphic::Ray< RayComponentType >::translated ( const math::Vector< RayComponentType, 3 > &  offset) const
inline

Get translated ray copy.

Parameters
offsetTranslation vector.
Returns
Ray copy with translated origin.

Definition at line 276 of file ray.hpp.

Here is the call graph for this function:

◆ validateDirection()

template<CanBeRayComponent RayComponentType>
static void utility::graphic::Ray< RayComponentType >::validateDirection ( const math::Vector< RayComponentType, 3 > &  direction)
inlinestaticprotected

Validate that a direction vector is non-zero.

Parameters
directionDirection vector to validate.
Exceptions
std::invalid_argumentif direction is the zero vector.

Definition at line 79 of file ray.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _direction

template<CanBeRayComponent RayComponentType>
math::Vector<RayComponentType, 3> utility::graphic::Ray< RayComponentType >::_direction
protected

Direction vector of the ray (must be non-zero).

Definition at line 72 of file ray.hpp.

◆ _origin

template<CanBeRayComponent RayComponentType>
Position<RayComponentType> utility::graphic::Ray< RayComponentType >::_origin
protected

Origin point of the ray.

Definition at line 67 of file ray.hpp.


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