SA_Maths
Sapphire Suite's C++ Maths Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SA::AABB2D< T > Struct Template Reference

AABB 2D Sapphire's class. More...

#include <AABB2D.hpp>

Public Member Functions

 AABB2D ()=default
 Default constructor.
 
 AABB2D (const Vec2< T > &_min, const Vec2< T > &_max)
 Value constructor from min and max.
 
 AABB2D (const AABB2D &_first, const AABB2D &_second)
 Merge 2 AABB box.
 
 AABB2D (const AABB3D< T > &_aabb3D) noexcept
 Constructor from AABB3D.
 
bool IsValid () const noexcept
 Wether this AABB has valid values (ie min < max);.
 
constexpr bool Equals (const AABB2D &_other, T _epsilon=std::numeric_limits< T >::epsilon()) const noexcept
 Compare 2 AABB2D.
 
constexpr bool operator== (const AABB2D &_rhs) const noexcept
 Compare 2 AABB equality.
 
constexpr bool operator!= (const AABB2D &_rhs) const noexcept
 Compare 2 AABB inequality.
 
bool IsCollidingX (const AABB2D &_other) const
 Perform collision test on X axis only.
 
bool IsCollidingY (const AABB2D &_other) const
 Perform collision test on Y axis only.
 
bool IsColliding (const AABB2D &_other) const
 Perform collision test on every axis.
 
float Width () const
 Compute width (X axis) from min and max.
 
float Height () const
 Compute height (Y axis) from min and max.
 
Vec2< T > Center () const
 Compute center from min and max.
 
float Area () const
 Compute area from min and max.
 

Static Public Member Functions

static AABB2D Merge (const AABB2D &_first, const AABB2D &_second)
 Merge 2 AABB2D box to create a big AABB2D which wrap both boxes.
 

Public Attributes

Vec2< T > min
 Min box component.
 
Vec2< T > max
 Max box component.
 

Detailed Description

template<typename T>
struct SA::AABB2D< T >

AABB 2D Sapphire's class.

Template Parameters
TType of the AABB.

Constructor & Destructor Documentation

◆ AABB2D() [1/3]

template<typename T >
SA::AABB2D< T >::AABB2D ( const Vec2< T > & _min,
const Vec2< T > & _max )

Value constructor from min and max.

Parameters
_minMin value
_maxMax value.

◆ AABB2D() [2/3]

template<typename T >
SA::AABB2D< T >::AABB2D ( const AABB2D< T > & _first,
const AABB2D< T > & _second )

Merge 2 AABB box.

Parameters
_firstFirst AABB to merge.
_secondSecond AABB to merge.

◆ AABB2D() [3/3]

template<typename T >
SA::AABB2D< T >::AABB2D ( const AABB3D< T > & _aabb3D)
noexcept

Constructor from AABB3D.

Parameters
_aabb3D3D AABB object.

Member Function Documentation

◆ Area()

template<typename T >
float SA::AABB2D< T >::Area ( ) const

Compute area from min and max.

Returns
AABB area

◆ Center()

template<typename T >
Vec2< T > SA::AABB2D< T >::Center ( ) const

Compute center from min and max.

Returns
AABB center.

◆ Equals()

template<typename T >
constexpr bool SA::AABB2D< T >::Equals ( const AABB2D< T > & _other,
T _epsilon = std::numeric_limits< T >::epsilon() ) const
constexprnoexcept

Compare 2 AABB2D.

Parameters
[in]_otherOther AABB to compare to.
[in]_epsilonEpsilon value for threshold comparison.
Returns
Whether this and _other are equal.

◆ Height()

template<typename T >
float SA::AABB2D< T >::Height ( ) const

Compute height (Y axis) from min and max.

Returns
AABB height.

◆ IsColliding()

template<typename T >
bool SA::AABB2D< T >::IsColliding ( const AABB2D< T > & _other) const

Perform collision test on every axis.

Parameters
_otherOther AABB box.
Returns
true if this and other collide on any axis.

◆ IsCollidingX()

template<typename T >
bool SA::AABB2D< T >::IsCollidingX ( const AABB2D< T > & _other) const

Perform collision test on X axis only.

Parameters
_otherOther AABB box.
Returns
true if this and other collide on X axis.

◆ IsCollidingY()

template<typename T >
bool SA::AABB2D< T >::IsCollidingY ( const AABB2D< T > & _other) const

Perform collision test on Y axis only.

Parameters
_otherOther AABB box.
Returns
true if this and other collide on Y axis.

◆ IsValid()

template<typename T >
bool SA::AABB2D< T >::IsValid ( ) const
noexcept

Wether this AABB has valid values (ie min < max);.

Returns
true if components are valid.

◆ Merge()

template<typename T >
static AABB2D SA::AABB2D< T >::Merge ( const AABB2D< T > & _first,
const AABB2D< T > & _second )
static

Merge 2 AABB2D box to create a big AABB2D which wrap both boxes.

Parameters
_firstFirst AABB object to merge.
_secondSecond AABB object to merge.
Returns
AABB2D Big AABB box from merge.

◆ operator!=()

template<typename T >
constexpr bool SA::AABB2D< T >::operator!= ( const AABB2D< T > & _rhs) const
constexprnoexcept

Compare 2 AABB inequality.

Parameters
[in]_rhsOther AABB to compare to.
Returns
Whether this and _rhs are non-equal.

◆ operator==()

template<typename T >
constexpr bool SA::AABB2D< T >::operator== ( const AABB2D< T > & _rhs) const
constexprnoexcept

Compare 2 AABB equality.

Parameters
[in]_rhsOther AABB to compare to.
Returns
Whether this and _rhs are equal.

◆ Width()

template<typename T >
float SA::AABB2D< T >::Width ( ) const

Compute width (X axis) from min and max.

Returns
AABB width.

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