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

Represents a rectangle in three dimensional space. More...

#include <CeresEngine/Math/Geometry.hpp>

Public Member Functions

 TRect ()=default
 
 TRect (const TVector3< T > &center, const Array< TVector3< T >, 2 > &axes, const Array< T, 2 > &extents)
 
Pair< Array< TVector3< T >, 2 >, T > getNearestPoint (const TRay< T > &ray) const
 Find the nearest points of the provided ray and the rectangle.
 
Pair< TVector3< T >, T > getNearestPoint (const TVector3< T > &point) const
 Find the nearest point on the rectangle to the provided point.
 
TRayIntersection< T > intersects (const TRay< T > &ray) const
 Ray/rectangle intersection.
 
const TVector3< T > & getCenter () const
 Gets the origin of the rectangle.
 
const TVector3< T > & getAxisHorz () const
 Returns the rectangle's horizontal axis.
 
const TVector3< T > & getAxisVert () const
 Returns the rectangle's vertical axis.
 
const T & getExtentHorz () const
 Gets the extent of the rectangle along its horizontal axis.
 
const T & getExtentVertical () const
 Gets the extent of the rectangle along its vertical axis.
 

Private Attributes

TVector3< T > mCenter = TVector3<T>(T(0.0))
 
TVector3< T > mAxisHorz = TVector3<T>(T(0.0))
 
TVector3< T > mAxisVert = TVector3<T>(T(0.0))
 
mExtentHorz = T(0.0)
 
mExtentVert = T(0.0)
 

Detailed Description

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

Represents a rectangle in three dimensional space.

It is represented by two axes that extend from the specified origin. Axes should be perpendicular to each other and they extend in both positive and negative directions from the origin by the amount specified by extents.

Constructor & Destructor Documentation

◆ TRect() [1/2]

template<typename T >
Math::TRect< T >::TRect ( )
default

◆ TRect() [2/2]

template<typename T >
Math::TRect< T >::TRect ( const TVector3< T > &  center,
const Array< TVector3< T >, 2 > &  axes,
const Array< T, 2 > &  extents 
)
inline

Member Function Documentation

◆ getAxisHorz()

template<typename T >
const TVector3< T > & Math::TRect< T >::getAxisHorz ( ) const
inline

Returns the rectangle's horizontal axis.

◆ getAxisVert()

template<typename T >
const TVector3< T > & Math::TRect< T >::getAxisVert ( ) const
inline

Returns the rectangle's vertical axis.

◆ getCenter()

template<typename T >
const TVector3< T > & Math::TRect< T >::getCenter ( ) const
inline

Gets the origin of the rectangle.

◆ getExtentHorz()

template<typename T >
const T & Math::TRect< T >::getExtentHorz ( ) const
inline

Gets the extent of the rectangle along its horizontal axis.

◆ getExtentVertical()

template<typename T >
const T & Math::TRect< T >::getExtentVertical ( ) const
inline

Gets the extent of the rectangle along its vertical axis.

◆ getNearestPoint() [1/2]

template<typename T >
Pair< Array< TVector3< T >, 2 >, T > Math::TRect< T >::getNearestPoint ( const TRay< T > &  ray) const

Find the nearest points of the provided ray and the rectangle.

Returns
A set of nearest points and nearest distance. First value in the set corresponds to nearest point on the ray, and the second to the nearest point on the rectangle. They are same in the case of intersection. When ray is parallel to the rectangle there are two sets of nearest points but only one the set nearest to the ray origin is returned.

◆ getNearestPoint() [2/2]

template<typename T >
Pair< TVector3< T >, T > Math::TRect< T >::getNearestPoint ( const TVector3< T > &  point) const

Find the nearest point on the rectangle to the provided point.

Returns
Nearest point and distance to nearest point.

◆ intersects()

template<typename T >
TRayIntersection< T > Math::TRect< T >::intersects ( const TRay< T > &  ray) const

Ray/rectangle intersection.

Returns
Boolean result and distance to intersection point.

Member Data Documentation

◆ mAxisHorz

template<typename T >
TVector3<T> Math::TRect< T >::mAxisHorz = TVector3<T>(T(0.0))
private

◆ mAxisVert

template<typename T >
TVector3<T> Math::TRect< T >::mAxisVert = TVector3<T>(T(0.0))
private

◆ mCenter

template<typename T >
TVector3<T> Math::TRect< T >::mCenter = TVector3<T>(T(0.0))
private

◆ mExtentHorz

template<typename T >
T Math::TRect< T >::mExtentHorz = T(0.0)
private

◆ mExtentVert

template<typename T >
T Math::TRect< T >::mExtentVert = T(0.0)
private

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