- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes

# AxisAlignedBoundingBox Class Reference

Search for all occurrences

## Detailed Description

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.

Examples:

  CurveBrush/CurveCreator.h, FixedFunctionMaterial/FixedFunctionMaterial.h, ImmediateModeRenderer/ImmediateModeRenderer.h, and ToonMaterial/ToonMaterial.h.

Definition at line 820 of file math.h.

`#include <math.h>`

List of all members.

## 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

## Constructor & Destructor Documentation

AxisAlignedBoundingBox | ( | void |  | ) | `[inline]`

Creates an empty bounding box.

Definition at line 824 of file math.h.

    { Reset(); };

AxisAlignedBoundingBox | ( | const Vector & | vStart,
|  | const Vector & | vEnd
| ) |  | `[inline]`

Creates an object by specifying two corners of the box.

Definition at line 827 of file math.h.

                                                                           :
            m_vStart( vStart ),
            m_vEnd( vEnd ) {};

AxisAlignedBoundingBox | ( | const Vector & | vCenter,
|  | float | fSize
| ) |  | `[inline]`

Creates an object by specifying the center of it and the distance of the sides from the center.

This will be a cube.

Definition at line 833 of file math.h.

        {
            Vector v( fSize, fSize, fSize );
            m_vStart = vCenter-v;
            m_vEnd   = vCenter+v;
        };

AxisAlignedBoundingBox | ( | const AxisAlignedBoundingBox & | cA | ) | `[inline]`

Creates an object by cloning another one.

Definition at line 841 of file math.h.

                                                                   :
        m_vStart( cA.m_vStart ),
        m_vEnd( cA.m_vEnd ) {};

## Member Function Documentation

AxisAlignedBoundingBox& operator= | ( | const AxisAlignedBoundingBox & | cBB | ) | `[inline]`

Assigns the value of a box object to another one.

Definition at line 846 of file math.h.

        {
            m_vStart = cBB.m_vStart;
            m_vEnd = cBB.m_vEnd;
            return *this;
        };

AxisAlignedBoundingBox& operator+= | ( | const AxisAlignedBoundingBox & | cBB | ) | `[inline]`

Extends the box to contain another one.

Definition at line 854 of file math.h.

        {
            for ( int i = 0; i < 8; i++ ) Extend( cBB[i] );
            return *this;
        };

bool operator== | ( | const AxisAlignedBoundingBox & | cBB | ) | const `[inline]`

Returns true if two boxes are identical, false otherwise.

Definition at line 861 of file math.h.

        {
            return m_vStart == cBB.m_vStart && m_vEnd == cBB.m_vEnd;
        };

void Reset | ( | void |  | ) | `[inline]`

Search for all occurrences

Makes the box empty.

Definition at line 867 of file math.h.

        {
            m_vStart.Set( 0, 0, 0 );
            m_vEnd.Set( -1, -1, -1 );
        };

void Serialize | ( | Stream & | s | ) |

Search for all occurrences

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 878 of file math.h.

            { return !(operator ==(cBox)); };

void Extend | ( | const Vector & |  | ) |

Search for all occurrences

Extends the box to contain the passed point.

void Extend | ( | const AxisAlignedBoundingBox & | bb | ) | `[inline]`

Search for all occurrences

Extends the box to contain another one.

Definition at line 886 of file math.h.

        {
            if ( !bb.IsEmpty() ) {
                Extend( bb.m_vStart );
                Extend( bb.m_vEnd );
            };
        };

void Transform | ( | const class Matrix & | mMatrix | ) |

Search for all occurrences

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]`

Search for all occurrences

Returns the maximum edge length of the box.

Definition at line 905 of file math.h.

    { return Max( Max( XSize(), YSize() ), ZSize() ); };

float XSize | ( | void |  | ) | const `[inline]`

Search for all occurrences

Returns the length of the box along the X axis.

Definition at line 908 of file math.h.

    { return m_vEnd.m_fX-m_vStart.m_fX; };

float YSize | ( | void |  | ) | const `[inline]`

Search for all occurrences

Returns the length of the box along the Y axis.

Definition at line 911 of file math.h.

    { return m_vEnd.m_fY-m_vStart.m_fY; };

float ZSize | ( | void |  | ) | const `[inline]`

Search for all occurrences

Returns the length of the box along the Y axis.

Definition at line 914 of file math.h.

    { return m_vEnd.m_fZ-m_vStart.m_fZ; };

float Volume | ( | void |  | ) | const `[inline]`

Search for all occurrences

Returns the volume of the box.

Definition at line 917 of file math.h.

    { return XSize()*YSize()*ZSize(); };

Vector Center | ( | void |  | ) | const `[inline]`

Search for all occurrences

Returns the center of the box.

Definition at line 920 of file math.h.

    { return (m_vStart+m_vEnd)*0.5f; };

bool IsPartOf | ( | const AxisAlignedBoundingBox & | cBB | ) | const `[inline]`

Search for all occurrences

Returns true if the passed-in box contains this box.

Definition at line 923 of file math.h.

        {
            return (
                m_vStart.m_fX >= cBB.m_vStart.m_fX && m_vEnd.m_fX <= cBB.m_vEnd.m_fX &&
                m_vStart.m_fY >= cBB.m_vStart.m_fY && m_vEnd.m_fY <= cBB.m_vEnd.m_fY &&
                m_vStart.m_fZ >= cBB.m_vStart.m_fZ && m_vEnd.m_fZ <= cBB.m_vEnd.m_fZ );
        };

bool IsTouching | ( | const AxisAlignedBoundingBox & | cBB | ) | const `[inline]`

Search for all occurrences

Returns true if the two boxes intersect at all.

Definition at line 932 of file math.h.

        {
            return (
                m_vStart.m_fX < cBB.m_vEnd.m_fX && m_vEnd.m_fX > cBB.m_vStart.m_fX &&
                m_vStart.m_fY < cBB.m_vEnd.m_fY && m_vEnd.m_fY > cBB.m_vStart.m_fY &&
                m_vStart.m_fZ < cBB.m_vEnd.m_fZ && m_vEnd.m_fZ > cBB.m_vStart.m_fZ );
        };

bool IsTouching | ( | const Vector & | vStart,
|  | const Vector & | vEnd,
|  | float & | fPlace
| ) |  | const

Search for all occurrences

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)

Parameters:

  [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]`

Search for all occurrences

Returns true if the box contains the specified point.

Definition at line 955 of file math.h.

        {
            return (
                m_vStart.m_fX <= cV.m_fX && m_vEnd.m_fX >= cV.m_fX &&
                m_vStart.m_fY <= cV.m_fY && m_vEnd.m_fY >= cV.m_fY &&
                m_vStart.m_fZ <= cV.m_fZ && m_vEnd.m_fZ >= cV.m_fZ );
        };

bool IsContaining | ( | const AxisAlignedBoundingBox & | b | ) | const `[inline]`

Search for all occurrences

Returns true if the box contains the specified box.

Definition at line 965 of file math.h.

            { return IsContaining( b.m_vStart ) && IsContaining( b.m_vEnd ); };

bool IsEmpty | ( | void |  | ) | const `[inline]`

Search for all occurrences

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.

Definition at line 971 of file math.h.

    { return m_vStart.x > m_vEnd.x; };

AxisAlignedBoundingBox operator* | ( | float | fFactor | ) | `[inline]`

Multiplies the box coordinates with a scalar value.

Definition at line 974 of file math.h.

        {
            return AxisAlignedBoundingBox( m_vStart*fFactor, m_vEnd*fFactor );
        };

## Member Data Documentation

Vector m_vStart

Search for all occurrences

Definition at line 977 of file math.h.

Vector m_vEnd

Search for all occurrences

Definition at line 980 of file math.h.

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

- Mudbox/math.h

AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox
AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox AxisAlignedBoundingBox