Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
nirt::core::aabbox3d< T > Class Template Reference

Axis aligned bounding box in 3d dimensional space. More...

#include <nirtcpp/core/engine/aabbox3d.hpp>

Public Member Functions

 aabbox3d ()
 Default Constructor.
 
 aabbox3d (const vector3d< T > &min, const vector3d< T > &max)
 Constructor with min edge and max edge.
 
 aabbox3d (const vector3d< T > &init)
 Constructor with only one point.
 
 aabbox3d (T minx, T miny, T minz, T maxx, T maxy, T maxz)
 Constructor with min edge and max edge as single values, not vectors.
 
bool operator== (const aabbox3d< T > &other) const
 Equality operator.
 
bool operator!= (const aabbox3d< T > &other) const
 Inequality operator.
 
void reset (T x, T y, T z)
 Resets the bounding box to a one-point box.
 
void reset (const aabbox3d< T > &initValue)
 Resets the bounding box.
 
void reset (const vector3d< T > &initValue)
 Resets the bounding box to a one-point box.
 
void addInternalPoint (const vector3d< T > &p)
 Adds a point to the bounding box.
 
void addInternalBox (const aabbox3d< T > &b)
 Adds another bounding box.
 
void addInternalPoint (T x, T y, T z)
 Adds a point to the bounding box.
 
vector3d< TgetCenter () const
 Get center of the bounding box.
 
vector3d< TgetExtent () const
 Get extent of the box (maximal distance of two points in the box)
 
T getRadius () const
 Get radius of the bounding sphere.
 
bool isEmpty () const
 Check if the box is empty.
 
T getVolume () const
 Get the volume enclosed by the box in cubed units.
 
T getArea () const
 Get the surface area of the box in squared units.
 
void getEdges (vector3d< T > *edges) const
 Stores all 8 edges of the box into an array.
 
void repair ()
 Repairs the box.
 
bool isValid () const
 
aabbox3d< TgetInterpolated (const aabbox3d< T > &other, f32 d) const
 Calculates a new interpolated bounding box.
 
bool isPointInside (const vector3d< T > &p) const
 Determines if a point is within this box.
 
bool isPointTotalInside (const vector3d< T > &p) const
 Determines if a point is within this box and not its borders.
 
bool isFullInside (const aabbox3d< T > &other) const
 Check if this box is completely inside the 'other' box.
 
aabbox3d< Tintersect (const aabbox3d< T > &other) const
 Returns the intersection of this box with another, if possible.
 
bool intersectsWithBox (const aabbox3d< T > &other) const
 Determines if the axis-aligned box intersects with another axis-aligned box.
 
bool intersectsWithLine (const line3d< T > &line) const
 Tests if the box intersects with a line.
 
bool intersectsWithLine (const vector3d< T > &linemiddle, const vector3d< T > &linevect, T halflength) const
 Tests if the box intersects with a line.
 
EIntersectionRelation3D classifyPlaneRelation (const plane3d< T > &plane) const
 Classifies a relation with a plane.
 

Public Attributes

vector3d< TMinEdge
 The near edge.
 
vector3d< TMaxEdge
 The far edge.
 

Detailed Description

template<class T>
class nirt::core::aabbox3d< T >

Axis aligned bounding box in 3d dimensional space.

Has some useful methods used with occlusion culling or clipping.

Member Function Documentation

◆ addInternalBox()

template<class T >
void nirt::core::aabbox3d< T >::addInternalBox ( const aabbox3d< T > &  b)
inline

Adds another bounding box.

The box grows bigger, if the new box was outside of the box.

Parameters
bOther bounding box to add into this box.

◆ addInternalPoint() [1/2]

template<class T >
void nirt::core::aabbox3d< T >::addInternalPoint ( const vector3d< T > &  p)
inline

Adds a point to the bounding box.

The box grows bigger, if point was outside of the box.

Parameters
pPoint to add into the box.

◆ addInternalPoint() [2/2]

template<class T >
void nirt::core::aabbox3d< T >::addInternalPoint ( T  x,
T  y,
T  z 
)
inline

Adds a point to the bounding box.

The box grows bigger, if point is outside of the box.

Parameters
xX coordinate of the point to add to this box.
yY coordinate of the point to add to this box.
zZ coordinate of the point to add to this box.

◆ classifyPlaneRelation()

template<class T >
EIntersectionRelation3D nirt::core::aabbox3d< T >::classifyPlaneRelation ( const plane3d< T > &  plane) const
inline

Classifies a relation with a plane.

Parameters
planePlane to classify relation to.
Returns
Returns ISREL3D_FRONT if the box is in front of the plane, ISREL3D_BACK if the box is behind the plane, and ISREL3D_CLIPPED if it is on both sides of the plane.

◆ getCenter()

template<class T >
vector3d< T > nirt::core::aabbox3d< T >::getCenter ( ) const
inline

Get center of the bounding box.

Returns
Center of the bounding box.

◆ getEdges()

template<class T >
void nirt::core::aabbox3d< T >::getEdges ( vector3d< T > *  edges) const
inline

Stores all 8 edges of the box into an array.

Parameters
edgesPointer to array of 8 edges.

◆ getExtent()

template<class T >
vector3d< T > nirt::core::aabbox3d< T >::getExtent ( ) const
inline

Get extent of the box (maximal distance of two points in the box)

Returns
Extent of the bounding box.

◆ getInterpolated()

template<class T >
aabbox3d< T > nirt::core::aabbox3d< T >::getInterpolated ( const aabbox3d< T > &  other,
f32  d 
) const
inline

Calculates a new interpolated bounding box.

d=0 returns other, d=1 returns this, all other values blend between the two boxes.

Parameters
otherOther box to interpolate between
dValue between 0.0f and 1.0f.
Returns
Interpolated box.

◆ getRadius()

template<class T >
T nirt::core::aabbox3d< T >::getRadius ( ) const
inline

Get radius of the bounding sphere.

Returns
Radius of the bounding sphere.

◆ intersectsWithBox()

template<class T >
bool nirt::core::aabbox3d< T >::intersectsWithBox ( const aabbox3d< T > &  other) const
inline

Determines if the axis-aligned box intersects with another axis-aligned box.

Parameters
otherOther box to check a intersection with.
Returns
True if there is an intersection with the other box, otherwise false.

◆ intersectsWithLine() [1/2]

template<class T >
bool nirt::core::aabbox3d< T >::intersectsWithLine ( const line3d< T > &  line) const
inline

Tests if the box intersects with a line.

Parameters
lineLine to test intersection with.
Returns
True if there is an intersection , else false.

◆ intersectsWithLine() [2/2]

template<class T >
bool nirt::core::aabbox3d< T >::intersectsWithLine ( const vector3d< T > &  linemiddle,
const vector3d< T > &  linevect,
T  halflength 
) const
inline

Tests if the box intersects with a line.

Parameters
linemiddleCenter of the line.
linevectVector of the line.
halflengthHalf length of the line.
Returns
True if there is an intersection, else false.

◆ isEmpty()

template<class T >
bool nirt::core::aabbox3d< T >::isEmpty ( ) const
inline

Check if the box is empty.

This means that there is no space between the min and max edge.

Returns
True if box is empty, else false.

◆ isFullInside()

template<class T >
bool nirt::core::aabbox3d< T >::isFullInside ( const aabbox3d< T > &  other) const
inline

Check if this box is completely inside the 'other' box.

Parameters
otherOther box to check against.
Returns
True if this box is completely inside the other box, otherwise false.

◆ isPointInside()

template<class T >
bool nirt::core::aabbox3d< T >::isPointInside ( const vector3d< T > &  p) const
inline

Determines if a point is within this box.

Border is included (IS part of the box)!

Parameters
pPoint to check.
Returns
True if the point is within the box and false if not

◆ isPointTotalInside()

template<class T >
bool nirt::core::aabbox3d< T >::isPointTotalInside ( const vector3d< T > &  p) const
inline

Determines if a point is within this box and not its borders.

Border is excluded (NOT part of the box)!

Parameters
pPoint to check.
Returns
True if the point is within the box and false if not.

◆ operator!=()

template<class T >
bool nirt::core::aabbox3d< T >::operator!= ( const aabbox3d< T > &  other) const
inline

Inequality operator.

Parameters
otherbox to compare with.
Returns
True if both boxes are different, else false.

◆ operator==()

template<class T >
bool nirt::core::aabbox3d< T >::operator== ( const aabbox3d< T > &  other) const
inline

Equality operator.

Parameters
otherbox to compare with.
Returns
True if both boxes are equal, else false.

◆ repair()

template<class T >
void nirt::core::aabbox3d< T >::repair ( )
inline

Repairs the box.

Necessary if for example MinEdge and MaxEdge are swapped.

◆ reset() [1/3]

template<class T >
void nirt::core::aabbox3d< T >::reset ( const aabbox3d< T > &  initValue)
inline

Resets the bounding box.

Parameters
initValueNew box to set this one to.

◆ reset() [2/3]

template<class T >
void nirt::core::aabbox3d< T >::reset ( const vector3d< T > &  initValue)
inline

Resets the bounding box to a one-point box.

Parameters
initValueNew point.

◆ reset() [3/3]

template<class T >
void nirt::core::aabbox3d< T >::reset ( T  x,
T  y,
T  z 
)
inline

Resets the bounding box to a one-point box.

Parameters
xX coord of the point.
yY coord of the point.
zZ coord of the point.

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

Nirtcpp    @cppfx.xyz

Esvcpp    esv::print