#include <math.h>
The box is usually referred by two corners, the start corner means the one whose coordinates are the smallest, while the end corner means the opposite.
Public Member Functions |
|
AxisAlignedBoundingBox (void) | |
Creates an empty bounding box. |
|
AxisAlignedBoundingBox (const Vector &vStart, const Vector &vEnd) | |
Creates an object by specifying two corners
of the box. |
|
AxisAlignedBoundingBox (const Vector &vCenter, float fSize) | |
Creates an object by specifying the center
of it and the distance of the sides from the center. |
|
AxisAlignedBoundingBox (const AxisAlignedBoundingBox &cA) | |
Creates an object by cloning another one.
|
|
AxisAlignedBoundingBox & | operator= (const AxisAlignedBoundingBox &cBB) |
Assigns the value of a box object to another
one. |
|
AxisAlignedBoundingBox & | operator+= (const AxisAlignedBoundingBox &cBB) |
Extends the box to contain another one.
|
|
bool | operator== (const AxisAlignedBoundingBox &cBB) const |
Returns true if two boxes are
identical, false otherwise. |
|
void | Reset (void) |
Makes the box empty. |
|
void | Serialize (Stream &s) |
Writes/reads the object data to/from a
stream. |
|
bool | operator!= (const AxisAlignedBoundingBox &cBox) const |
returns true if the two boxes are
different, false otherwise. |
|
void | Extend (const Vector &) |
Extends the box to contain the passed point.
|
|
void | Extend (const AxisAlignedBoundingBox &bb) |
Extends the box to contain another one.
|
|
void | Transform (const class Matrix &mMatrix) |
Transforms the box with the passed-in
matrix, and returns the smallest box which contains the result.
|
|
Vector | operator[] (int iCornerIndex) const |
Returns the corners of the box. Valid
indexes are 0-7. |
|
float | Size (void) const |
Returns the maximum edge length of the box.
|
|
float | XSize (void) const |
Returns the length of the box along the X
axis. |
|
float | YSize (void) const |
Returns the length of the box along the Y
axis. |
|
float | ZSize (void) const |
Returns the length of the box along the Y
axis. |
|
float | Volume (void) const |
Returns the volume of the box. |
|
Vector | Center (void) const |
Returns the center of the box. |
|
bool | IsPartOf (const AxisAlignedBoundingBox &cBB) const |
Returns true if the passed-in box
contains this box. |
|
bool | IsTouching (const AxisAlignedBoundingBox &cBB) const |
Returns true if the two boxes
intersect at all. |
|
bool | IsTouching (const Vector &vStart, const Vector &vEnd, float &fPlace) const |
Returns true if the box intersects
any part of a specified line. |
|
bool | IsContaining (const Vector &cV) const |
Returns true if the box contains the
specified point. |
|
bool | IsContaining (const AxisAlignedBoundingBox &b) const |
Returns true if the box contains the
specified box. |
|
bool | IsEmpty (void) const |
Returns true if the box is empy.
|
|
AxisAlignedBoundingBox | operator * (float fFactor) |
Multiplies the box coordinates with a scalar
value. |
|
Public Attributes |
|
Vector | m_vStart |
Vector | m_vEnd |
|
Creates an empty bounding box. 00533 { Reset(); }; |
|
Creates an object by specifying two corners of the box. |
|
Creates an object by specifying the center of it and the distance of the sides from the center. This will be a cube. |
|
Creates an object by cloning another one. |
|
Assigns the value of a box object to another one. |
|
Extends the box to contain another one. 00564 { 00565 for ( int i = 0; i < 8; i++ ) Extend( cBB[i] ); 00566 return *this; 00567 }; |
|
Returns true if two boxes are identical, false otherwise. |
|
Makes the box empty. |
|
Writes/reads the object data to/from a stream. |
|
returns true if the two boxes are different, false otherwise. 00588 { return !(operator ==(cBox)); }; |
|
Extends the box to contain the passed point. |
|
Extends the box to contain another one. |
|
Transforms the box with the passed-in matrix, and returns the smallest box which contains the result. This is usually larger than the original box, because the transformation might rotate the box out of axis alignment. |
|
Returns the corners of the box. Valid indexes are 0-7. |
|
Returns the maximum edge length of the box. |
|
Returns the length of the box along the X axis. |
|
Returns the length of the box along the Y axis. |
|
Returns the length of the box along the Y axis. |
|
Returns the volume of the box. |
|
Returns the center of the box. 00629 { return (m_vStart+m_vEnd)*0.5f; }; |
|
Returns true if the passed-in box contains this box. |
|
Returns true if the two boxes intersect at all. |
|
Returns true if the box intersects any part of a specified line. If there is an intersection, then a point guaranteed to be inside the box is returned in the third argument (fPlace). That argument represents a location along the line from vStart to vEnd. (Location = vStart + fPlace*vEnd)
|
|
Returns true if the box contains the specified point. |
|
Returns true if the box contains the specified box. 00675 { return IsContaining( b.m_vStart ) && IsContaining( b.m_vEnd ); }; |
|
Returns true if the box is empy. Note that when the start and end corners are equal then the box is not treated as empty. |
|
Multiplies the box coordinates with a scalar value. 00684 { 00685 return AxisAlignedBoundingBox( m_vStart*fFactor, m_vEnd*fFactor ); 00686 }; |
|
|