Represents a bounding box whose axes are aligned with the coordinate system.
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.
#include <math.h>
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 |
AxisAlignedBoundingBox | ( | void | ) | [inline] |
AxisAlignedBoundingBox | ( | const Vector & | vStart, |
const Vector & | vEnd | ||
) | [inline] |
AxisAlignedBoundingBox | ( | const Vector & | vCenter, |
float | fSize | ||
) | [inline] |
AxisAlignedBoundingBox | ( | const AxisAlignedBoundingBox & | cA | ) | [inline] |
AxisAlignedBoundingBox& operator= | ( | const AxisAlignedBoundingBox & | cBB | ) | [inline] |
AxisAlignedBoundingBox& operator+= | ( | const AxisAlignedBoundingBox & | cBB | ) | [inline] |
bool operator== | ( | const AxisAlignedBoundingBox & | cBB | ) | const [inline] |
void Reset | ( | void | ) | [inline] |
Makes the box empty.
void Serialize | ( | Stream & | s | ) |
Writes/reads the object data to/from a stream.
bool operator!= | ( | const AxisAlignedBoundingBox & | cBox | ) | const [inline] |
returns true if the two boxes are different, false otherwise.
Definition at line 874 of file math.h.
{ return !(operator ==(cBox)); };
void Extend | ( | const Vector & | ) |
Extends the box to contain the passed point.
void Extend | ( | const AxisAlignedBoundingBox & | bb | ) | [inline] |
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.
This is usually larger than the original box, because the transformation might rotate the box out of axis alignment.
Vector operator[] | ( | int | iCornerIndex | ) | const |
Returns the corners of the box. Valid indexes are 0-7.
float Size | ( | void | ) | const [inline] |
float XSize | ( | void | ) | const [inline] |
Returns the length of the box along the X axis.
float YSize | ( | void | ) | const [inline] |
Returns the length of the box along the Y axis.
float ZSize | ( | void | ) | const [inline] |
Returns the length of the box along the Y axis.
float Volume | ( | void | ) | const [inline] |
Vector Center | ( | void | ) | const [inline] |
Returns the center of the box.
bool IsPartOf | ( | const AxisAlignedBoundingBox & | cBB | ) | const [inline] |
Returns true if the passed-in box contains this box.
bool IsTouching | ( | const AxisAlignedBoundingBox & | cBB | ) | const [inline] |
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)
[in] | vStart | A point (represented as a Vector) defining the start of the line |
[in] | vEnd | A point (represented as a Vector) defining the end of the line |
[out] | fPlace | A number between 0.0 and 1.0, defining a position along the line that is guaranteed to be inside the box (if true was returned). |
bool IsContaining | ( | const Vector & | cV | ) | const [inline] |
bool IsContaining | ( | const AxisAlignedBoundingBox & | b | ) | const [inline] |
Returns true if the box contains the specified box.
Definition at line 961 of file math.h.
{ return IsContaining( b.m_vStart ) && IsContaining( b.m_vEnd ); };
bool IsEmpty | ( | void | ) | const [inline] |
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.
AxisAlignedBoundingBox operator* | ( | float | fFactor | ) | [inline] |
Multiplies the box coordinates with a scalar value.
Definition at line 970 of file math.h.
{ return AxisAlignedBoundingBox( m_vStart*fFactor, m_vEnd*fFactor ); };