Saga3D API Documentation  1.0-RC4
saga::core::aabbox3d< T > Class Template Reference

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

#include <aabbox3d.h>

Public Member Functions

 aabbox3d ()
 Default Constructor. More...
 
 aabbox3d (const glm::vec3 &min, const glm::vec3 &max)
 Constructor with min edge and max edge. More...
 
 aabbox3d (const glm::vec3 &init)
 Constructor with only one point. More...
 
 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. More...
 
bool operator== (const aabbox3d< T > &other) const
 Equality operator. More...
 
bool operator!= (const aabbox3d< T > &other) const
 Inequality operator. More...
 
void reset (T x, T y, T z)
 Resets the bounding box to a one-point box. More...
 
void reset (const aabbox3d< T > &initValue)
 Resets the bounding box. More...
 
void reset (const glm::vec3 &initValue)
 Resets the bounding box to a one-point box. More...
 
void addInternalPoint (const glm::vec3 &p)
 Adds a point to the bounding box. More...
 
void addInternalBox (const aabbox3d< T > &b)
 Adds another bounding box. More...
 
void addInternalPoint (T x, T y, T z)
 Adds a point to the bounding box. More...
 
glm::vec3 getCenter () const
 Get center of the bounding box. More...
 
glm::vec3 getExtent () const
 Get extent of the box (maximal distance of two points in the box) More...
 
getRadius () const
 Get radius of the bounding sphere. More...
 
bool isEmpty () const
 Check if the box is empty. More...
 
getVolume () const
 Get the volume enclosed by the box in cubed units. More...
 
getArea () const
 Get the surface area of the box in squared units. More...
 
void getEdges (glm::vec3 *edges) const
 Stores all 8 edges of the box into an array. More...
 
void repair ()
 Repairs the box. More...
 
aabbox3d< T > getInterpolated (const aabbox3d< T > &other, float d) const
 Calculates a new interpolated bounding box. More...
 
bool isPointInside (const glm::vec3 &p) const
 Determines if a point is within this box. More...
 
bool isPointTotalInside (const glm::vec3 &p) const
 Determines if a point is within this box and not its borders. More...
 
bool isFullInside (const aabbox3d< T > &other) const
 Check if this box is completely inside the 'other' box. More...
 
aabbox3d< T > intersect (const aabbox3d< T > &other) const
 Returns the intersection of this box with another, if possible. More...
 
bool intersectsWithBox (const aabbox3d< T > &other) const
 Determines if the axis-aligned box intersects with another axis-aligned box. More...
 
bool intersectsWithLine (const line3d< T > &line) const
 Tests if the box intersects with a line. More...
 
bool intersectsWithLine (const glm::vec3 &linemiddle, const glm::vec3 &linevect, T halflength) const
 Tests if the box intersects with a line. More...
 
EIntersectionRelation3D classifyPlaneRelation (const plane3d< T > &plane) const
 Classifies a relation with a plane. More...
 

Public Attributes

glm::vec3 MinEdge
 The near edge. More...
 
glm::vec3 MaxEdge
 The far edge. More...
 

Detailed Description

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

Axis aligned bounding box in 3d dimensional space.

Has some useful methods used with occlusion culling or clipping.

Definition at line 20 of file aabbox3d.h.

Constructor & Destructor Documentation

◆ aabbox3d() [1/4]

template<class T >
saga::core::aabbox3d< T >::aabbox3d ( )
inline

Default Constructor.

Definition at line 25 of file aabbox3d.h.

◆ aabbox3d() [2/4]

template<class T >
saga::core::aabbox3d< T >::aabbox3d ( const glm::vec3 &  min,
const glm::vec3 &  max 
)
inline

Constructor with min edge and max edge.

Definition at line 27 of file aabbox3d.h.

◆ aabbox3d() [3/4]

template<class T >
saga::core::aabbox3d< T >::aabbox3d ( const glm::vec3 &  init)
inline

Constructor with only one point.

Definition at line 29 of file aabbox3d.h.

◆ aabbox3d() [4/4]

template<class T >
saga::core::aabbox3d< T >::aabbox3d ( minx,
miny,
minz,
maxx,
maxy,
maxz 
)
inline

Constructor with min edge and max edge as single values, not vectors.

Definition at line 31 of file aabbox3d.h.

Member Function Documentation

◆ addInternalBox()

template<class T >
void saga::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.

Definition at line 81 of file aabbox3d.h.

◆ addInternalPoint() [1/2]

template<class T >
void saga::core::aabbox3d< T >::addInternalPoint ( const glm::vec3 &  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.

Definition at line 73 of file aabbox3d.h.

◆ addInternalPoint() [2/2]

template<class T >
void saga::core::aabbox3d< T >::addInternalPoint ( x,
y,
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.

Definition at line 92 of file aabbox3d.h.

◆ classifyPlaneRelation()

template<class T >
EIntersectionRelation3D saga::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.

Definition at line 310 of file aabbox3d.h.

◆ getArea()

template<class T >
T saga::core::aabbox3d< T >::getArea ( ) const
inline

Get the surface area of the box in squared units.

Definition at line 141 of file aabbox3d.h.

◆ getCenter()

template<class T >
glm::vec3 saga::core::aabbox3d< T >::getCenter ( ) const
inline

Get center of the bounding box.

Returns
Center of the bounding box.

Definition at line 105 of file aabbox3d.h.

◆ getEdges()

template<class T >
void saga::core::aabbox3d< T >::getEdges ( glm::vec3 *  edges) const
inline

Stores all 8 edges of the box into an array.

Parameters
edgesPointer to array of 8 edges.

Definition at line 149 of file aabbox3d.h.

◆ getExtent()

template<class T >
glm::vec3 saga::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.

Definition at line 112 of file aabbox3d.h.

◆ getInterpolated()

template<class T >
aabbox3d<T> saga::core::aabbox3d< T >::getInterpolated ( const aabbox3d< T > &  other,
float  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.

Definition at line 197 of file aabbox3d.h.

◆ getRadius()

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

Get radius of the bounding sphere.

Returns
Radius of the bounding sphere.

Definition at line 119 of file aabbox3d.h.

◆ getVolume()

template<class T >
T saga::core::aabbox3d< T >::getVolume ( ) const
inline

Get the volume enclosed by the box in cubed units.

Definition at line 134 of file aabbox3d.h.

◆ intersect()

template<class T >
aabbox3d<T> saga::core::aabbox3d< T >::intersect ( const aabbox3d< T > &  other) const
inline

Returns the intersection of this box with another, if possible.

Definition at line 237 of file aabbox3d.h.

◆ intersectsWithBox()

template<class T >
bool saga::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.

Definition at line 259 of file aabbox3d.h.

◆ intersectsWithLine() [1/2]

template<class T >
bool saga::core::aabbox3d< T >::intersectsWithLine ( const glm::vec3 &  linemiddle,
const glm::vec3 &  linevect,
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.

Definition at line 279 of file aabbox3d.h.

◆ intersectsWithLine() [2/2]

template<class T >
bool saga::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.

Definition at line 268 of file aabbox3d.h.

◆ isEmpty()

template<class T >
bool saga::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.

Definition at line 128 of file aabbox3d.h.

◆ isFullInside()

template<class T >
bool saga::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.

Definition at line 230 of file aabbox3d.h.

◆ isPointInside()

template<class T >
bool saga::core::aabbox3d< T >::isPointInside ( const glm::vec3 &  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

Definition at line 208 of file aabbox3d.h.

◆ isPointTotalInside()

template<class T >
bool saga::core::aabbox3d< T >::isPointTotalInside ( const glm::vec3 &  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.

Definition at line 219 of file aabbox3d.h.

◆ operator!=()

template<class T >
bool saga::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.

Definition at line 41 of file aabbox3d.h.

◆ operator==()

template<class T >
bool saga::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.

Definition at line 37 of file aabbox3d.h.

◆ repair()

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

Repairs the box.

Necessary if for example MinEdge and MaxEdge are swapped.

Definition at line 179 of file aabbox3d.h.

◆ reset() [1/3]

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

Resets the bounding box.

Parameters
initValueNew box to set this one to.

Definition at line 57 of file aabbox3d.h.

◆ reset() [2/3]

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

Resets the bounding box to a one-point box.

Parameters
initValueNew point.

Definition at line 64 of file aabbox3d.h.

◆ reset() [3/3]

template<class T >
void saga::core::aabbox3d< T >::reset ( x,
y,
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.

Definition at line 49 of file aabbox3d.h.

Member Data Documentation

◆ MaxEdge

template<class T >
glm::vec3 saga::core::aabbox3d< T >::MaxEdge

The far edge.

Definition at line 346 of file aabbox3d.h.

◆ MinEdge

template<class T >
glm::vec3 saga::core::aabbox3d< T >::MinEdge

The near edge.

Definition at line 343 of file aabbox3d.h.


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