Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::OrientedBox< T > Class Template Reference

Math class that represents an oriented three dimensional box. More...

Public Member Functions

 OrientedBox (T X, T Y, T Z, T Width, T Height, T Depth)
 Constructs a OrientedBox object from its position and sizes. More...
 
 OrientedBox (const Box< T > &box)
 Constructs a OrientedBox object from a box. More...
 
 OrientedBox (const Vector3< T > &vec1, const Vector3< T > &vec2)
 Constructs a OrientedBox object from two vectors representing point of the space (X, Y, Z) will be the components minimum of the two vectors and the (width, height, depth) will be the components maximum - minimum. More...
 
template<typename U >
 OrientedBox (const OrientedBox< U > &orientedBox)
 Constructs a OrientedBox object from another type of OrientedBox. More...
 
 OrientedBox (const OrientedBox &orientedBox)=default
 
const Vector3< T > & GetCorner (BoxCorner corner) const
 Gets the Vector3 for the corner. More...
 
bool IsValid () const
 Checks whether this oriented box is valid. More...
 
OrientedBoxMakeZero ()
 Makes the oriented box position (0, 0, 0) and lengths (0, 0, 0) More...
 
OrientedBoxSet (T X, T Y, T Z, T Width, T Height, T Depth)
 Sets the components of the oriented box. More...
 
OrientedBoxSet (const Box< T > &box)
 Sets the components of the oriented box from a box. More...
 
OrientedBoxSet (const OrientedBox &orientedBox)
 Sets the components of the oriented box with components from another. More...
 
OrientedBoxSet (const Vector3< T > &vec1, const Vector3< T > &vec2)
 Sets a OrientedBox object from two vectors representing point of the space (X, Y, Z) will be the components minimum of the two vectors and the (width, height, depth) will be the components maximum - minimum. More...
 
template<typename U >
OrientedBoxSet (const OrientedBox< U > &orientedBox)
 
String ToString () const
 Gives a string representation. More...
 
void Update (const Matrix4< T > &transformMatrix)
 Updates the corners of the box. More...
 
void Update (const Vector3< T > &transformMatrix)
 Updates the corners of the box. More...
 
 operator Vector3< T > * ()
 Converts oriented box to pointer of Vector3 to its own corners. More...
 
 operator const Vector3< T > * () const
 Converts oriented box to pointer of Vector3 to its own corners. More...
 
Vector3< T > & operator() (unsigned int i)
 Gets the ith corner of the oriented box. More...
 
Vector3< T > operator() (unsigned int i) const
 Gets the ith corner of the oriented box. More...
 
OrientedBox operator* (T scalar) const
 Multiplies the lengths with the scalar. More...
 
OrientedBoxoperator= (const OrientedBox &other)=default
 
OrientedBoxoperator*= (T scalar)
 Multiplies the lengths of this oriented box with the scalar. More...
 
bool operator== (const OrientedBox &box) const
 Compares the oriented box to other one. More...
 
bool operator!= (const OrientedBox &box) const
 Compares the oriented box to other one. More...
 
template<typename U >
OrientedBox< T > & Set (const OrientedBox< U > &orientedBox)
 Sets the components of the orientedBox from another type of OrientedBox. More...
 

Static Public Member Functions

static OrientedBox Lerp (const OrientedBox &from, const OrientedBox &to, T interpolation)
 Interpolates the oriented box to other one with a factor of interpolation. More...
 
static OrientedBox Zero ()
 Shorthand for the oriented box (0, 0, 0, 0, 0, 0) More...
 

Public Attributes

Box< T > localBox
 

Detailed Description

template<typename T>
class Nz::OrientedBox< T >

Math class that represents an oriented three dimensional box.

Remarks
You need to call Update not to have undefined behaviour

Constructor & Destructor Documentation

◆ OrientedBox() [1/4]

template<typename T>
Nz::OrientedBox< T >::OrientedBox ( X,
Y,
Z,
Width,
Height,
Depth 
)

Constructs a OrientedBox object from its position and sizes.

Parameters
XX component of position
YY component of position
ZZ component of position
WidthWidth of the box (following X)
HeightHeight of the box (following Y)
DepthDepth of the box (following Z)

◆ OrientedBox() [2/4]

template<typename T>
Nz::OrientedBox< T >::OrientedBox ( const Box< T > &  box)

Constructs a OrientedBox object from a box.

Parameters
boxBox<T> object

◆ OrientedBox() [3/4]

template<typename T>
Nz::OrientedBox< T >::OrientedBox ( const Vector3< T > &  vec1,
const Vector3< T > &  vec2 
)

Constructs a OrientedBox object from two vectors representing point of the space (X, Y, Z) will be the components minimum of the two vectors and the (width, height, depth) will be the components maximum - minimum.

Parameters
vec1First point
vec2Second point

◆ OrientedBox() [4/4]

template<typename T >
template<typename U >
Nz::OrientedBox< T >::OrientedBox ( const OrientedBox< U > &  orientedBox)
explicit

Constructs a OrientedBox object from another type of OrientedBox.

Parameters
orientedBoxOrientedBox of type U to convert to type T

Member Function Documentation

◆ GetCorner()

template<typename T >
const Vector3< T > & Nz::OrientedBox< T >::GetCorner ( BoxCorner  corner) const

Gets the Vector3 for the corner.

Returns
The position of the corner of the oriented box according to enum BoxCorner
Parameters
cornerEnumeration of type BoxCorner
Remarks
If enumeration is not defined in BoxCorner, a NazaraError is thrown and a Vector3 uninitialised is returned

◆ IsValid()

template<typename T >
bool Nz::OrientedBox< T >::IsValid ( ) const

Checks whether this oriented box is valid.

Returns
true if the oriented box has a strictly positive width, height and depth

◆ Lerp()

template<typename T>
OrientedBox< T > Nz::OrientedBox< T >::Lerp ( const OrientedBox< T > &  from,
const OrientedBox< T > &  to,
interpolation 
)
static

Interpolates the oriented box to other one with a factor of interpolation.

Returns
A new oriented box which is the interpolation of two oriented boxes
Parameters
fromInitial oriented box
toTarget oriented box
interpolationFactor of interpolation
Remarks
interpolation is meant to be between 0 and 1, other values are potentially undefined behavior
With NAZARA_DEBUG, a NazaraError is thrown and Zero() is returned
See also
Lerp

◆ MakeZero()

template<typename T >
OrientedBox< T > & Nz::OrientedBox< T >::MakeZero ( )

Makes the oriented box position (0, 0, 0) and lengths (0, 0, 0)

Returns
A reference to this oriented box with position (0, 0, 0) and lengths (0, 0, 0)
See also
Zero

◆ operator const Vector3< T > *()

template<typename T >
Nz::OrientedBox< T >::operator const Vector3< T > * ( ) const

Converts oriented box to pointer of Vector3 to its own corners.

Returns
A const pointer to the own corners
Remarks
Access to index greather than BoxCorner_Max is undefined behavior

◆ operator Vector3< T > *()

template<typename T >
Nz::OrientedBox< T >::operator Vector3< T > * ( )

Converts oriented box to pointer of Vector3 to its own corners.

Returns
A pointer to the own corners
Remarks
Access to index greather than BoxCorner_Max is undefined behavior

◆ operator!=()

template<typename T >
bool Nz::OrientedBox< T >::operator!= ( const OrientedBox< T > &  box) const

Compares the oriented box to other one.

Returns
false if the two oriented boxes are the same
Parameters
boxOther oriented box to compare with

◆ operator()() [1/2]

template<typename T >
Vector3< T > & Nz::OrientedBox< T >::operator() ( unsigned int  i)

Gets the ith corner of the oriented box.

Returns
A reference to this corner
Remarks
Produce a NazaraError if you try to access to index greather than BoxCorner_Max with NAZARA_MATH_SAFE defined. If not, it is undefined behaviour
Exceptions
std::out_of_rangeif NAZARA_MATH_SAFE is defined and you try to acces to index greather than BoxCorner_Max

◆ operator()() [2/2]

template<typename T >
Vector3< T > Nz::OrientedBox< T >::operator() ( unsigned int  i) const

Gets the ith corner of the oriented box.

Returns
A reference to this corner
Remarks
Produce a NazaraError if you try to access to index greather than BoxCorner_Max with NAZARA_MATH_SAFE defined. If not, it is undefined behaviour
Exceptions
std::out_of_rangeif NAZARA_MATH_SAFE is defined and you try to acces to index greather than BoxCorner_Max

◆ operator*()

template<typename T>
OrientedBox< T > Nz::OrientedBox< T >::operator* ( scalar) const

Multiplies the lengths with the scalar.

Returns
A OrientedBox where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar
Parameters
scalarThe scalar to multiply width, height and depth with

◆ operator*=()

template<typename T>
OrientedBox< T > & Nz::OrientedBox< T >::operator*= ( scalar)

Multiplies the lengths of this oriented box with the scalar.

Returns
A reference to this oriented box where lengths are the product of these lengths and the scalar
Parameters
scalarThe scalar to multiply width, height and depth with

◆ operator==()

template<typename T >
bool Nz::OrientedBox< T >::operator== ( const OrientedBox< T > &  box) const

Compares the oriented box to other one.

Returns
true if the two oriented boxes are the same
Parameters
boxOther oriented box to compare with

◆ Set() [1/5]

template<typename T>
OrientedBox< T > & Nz::OrientedBox< T >::Set ( X,
Y,
Z,
Width,
Height,
Depth 
)

Sets the components of the oriented box.

Returns
A reference to this oriented box
Parameters
XX position
YY position
ZZ position
WidthWidth of the oriented box (following X)
HeightHeight of the oriented box (following Y)
DepthDepth of the oriented box (following Z)

◆ Set() [2/5]

template<typename T>
OrientedBox< T > & Nz::OrientedBox< T >::Set ( const Box< T > &  box)

Sets the components of the oriented box from a box.

Returns
A reference to this oriented box
Parameters
boxBox<T> object

◆ Set() [3/5]

template<typename T>
OrientedBox< T > & Nz::OrientedBox< T >::Set ( const OrientedBox< T > &  orientedBox)

Sets the components of the oriented box with components from another.

Returns
A reference to this oriented box
Parameters
orientedBoxThe other OrientedBox

◆ Set() [4/5]

template<typename T>
OrientedBox< T > & Nz::OrientedBox< T >::Set ( const Vector3< T > &  vec1,
const Vector3< T > &  vec2 
)

Sets a OrientedBox object from two vectors representing point of the space (X, Y, Z) will be the components minimum of the two vectors and the (width, height, depth) will be the components maximum - minimum.

Parameters
vec1First point
vec2Second point

◆ Set() [5/5]

template<typename T>
template<typename U >
OrientedBox<T>& Nz::OrientedBox< T >::Set ( const OrientedBox< U > &  orientedBox)

Sets the components of the orientedBox from another type of OrientedBox.

Returns
A reference to this orientedBox
Parameters
orientedBoxOrientedBox of type U to convert its components

◆ ToString()

template<typename T >
String Nz::OrientedBox< T >::ToString ( ) const

Gives a string representation.

Returns
A string representation of the object: "OrientedBox(...)"

◆ Update() [1/2]

template<typename T>
void Nz::OrientedBox< T >::Update ( const Matrix4< T > &  transformMatrix)

Updates the corners of the box.

Parameters
transformMatrixMatrix4 which represents the transformation to apply on the local box

◆ Update() [2/2]

template<typename T>
void Nz::OrientedBox< T >::Update ( const Vector3< T > &  translation)

Updates the corners of the box.

Parameters
translationVector3 which represents the translation to apply on the local box

◆ Zero()

template<typename T >
OrientedBox< T > Nz::OrientedBox< T >::Zero ( )
static

Shorthand for the oriented box (0, 0, 0, 0, 0, 0)

Returns
A oriented box with position (0, 0, 0) and lengths (0, 0, 0)
See also
MakeZero

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