Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | Namespace Members | Class Members | Related Pages

AxisAlignedBox Class Reference
[XEngineMath Library]

Inheritance diagram for AxisAlignedBox:

Inheritance graph
[legend]
List of all members.

Detailed Description

This class represents an axis-aligned box. It is specified by the center of the box and the extents along the axes or by a minimum and maximum poing (which can be thought of as the bottom, left, front point and the top, right, back point of the axis-aligned box). Internally, the box is stored using the minimum and maximum point.


Public Member Functions

 AxisAlignedBox ()
 Default constructor.
 AxisAlignedBox (const Vector3 &minPoint, const Vector3 &maxPoint)
 Constructor for minimum and maximum points.
 AxisAlignedBox (const Point< 3 > &center, const Vector3 &extents)
 Constructor for center point and extents vector.
void Set (const Vector3 &minPoint, const Vector3 &maxPoint)
 Sets the minimum and maximum points of this box.
void Set (const Point< 3 > &center, const Vector3 &extents)
 Sets the center point and extents of the box.
void SetMinPoint (const Vector3 &minPoint)
 Sets the minimum point of this box.
void SetMaxPoint (const Vector3 &maxPoint)
 Sets the maximum point of this box.
void SetCenter (const Vector3 &center)
 Sets the box's center point.
void SetExtents (const Vector3 &extents)
 Sets the box's extents along each axis.
const Vector3GetMinPoint () const
 Returns the minimum point of this box.
const Vector3GetMaxPoint () const
 Returns the maximum point of this box.
Vector3 GetCenter () const
 Returns the center of the box.
Vector3 GetExtents () const
 Returns the box's extents along each axis.
template<typename OutputIteratorT>
void GetCornerVertices (OutputIteratorT it) const
 Returns the 8 corner vertices of this box.
Vector3 GetCornerVertex (size_t index) const
 Returns one of the 8 corner vertices of this box.
template<typename OutputIteratorT>
void GetPlanes (OutputIteratorT it) const
 Returns the 6 planes of this box.
Plane GetPlane (size_t index) const
 Returns one of the 6 planes of this box.
template<typename OutputIteratorT>
void GetRectangles (OutputIteratorT it) const
 Returns the 6 rectangles that make up this box.
Rectangle< 3 > GetRectangle (size_t index) const
 Returns one of the 6 rectangles of this box.
std::pair< Vector3, Vector3GetFarPoints (const Plane &plane) const
 Returns the positive and negative far points of this box in relation to the given plane.
bool operator== (const AxisAlignedBox &b) const
 Equality operator.
bool operator!= (const AxisAlignedBox &b) const
 Inequality operator.
virtual void Transform (const Matrix4x4 &m)
 Transforms this object by the given matrix.
virtual void Transform (const Math::Transform &m)
 Transforms this object by the given affine transform.
virtual real GetVolume () const
 Returns the volume of this object.
virtual bool Contains (const Point< 3 > &point) const
 Returns true if this volume contains the given point.
template<typename InputIteratorT>
void SetBound (InputIteratorT itBegin, InputIteratorT itEnd)
 Sets this volume so that it bounds all the vertices specified by the given Vector3 iterators.
virtual void SetBound (const AxisAlignedBox &box)
 Sets this volume to bound the given axis-aligned box.
virtual void SetBound (const Box &box)
 Sets this volume to bound the given box.
virtual void SetBound (const Sphere &sphere)
 Sets this volume to bound the given sphere.
virtual void SetBound (const Frustum &frustum)
 Sets this volume to bound the given frustum.
virtual void Merge (const AxisAlignedBox &box)
 Grows this volume so that it also bounds the given axis-aligned box.
virtual void Merge (const Box &box)
 Grows this volume so that it also contains the given box.
virtual void Merge (const Sphere &sphere)
 Grows this volume so that it also contains the given sphere.

Static Public Member Functions

static std::pair< size_t,
size_t > 
GetFarPointIndices (const Plane &plane)
 Returns the indices of the positive and negative far points of an axis-aligned box in relation to the given plane.


Constructor & Destructor Documentation

AxisAlignedBox  ) 
 

Default constructor.

Warning:
Does not initialize the axis aligned box.

AxisAlignedBox const Vector3 minPoint,
const Vector3 maxPoint
 

Constructor for minimum and maximum points.

AxisAlignedBox const Point< 3 > &  center,
const Vector3 extents
 

Constructor that creates an axis-aligned box with the given center and extents. The first parameter is changed to Point<3> to distinguish this constructor from the minimum, maximum point constructor.


Member Function Documentation

bool Contains const Point< 3 > &  point  )  const [virtual]
 

Returns true if this volume contains the given point.

Implements Volume.

Vector3 GetCenter  )  const
 

Returns the center of the box.

Vector3 GetCornerVertex size_t  index  )  const
 

Returns one of the 8 corner vertices of this box. The given index corresponds to the vertices of the box as follows:

  • Index 0 = left, bottom, back
  • Index 1 = right, bottom, back
  • Index 2 = left, top, back
  • Index 3 = right, top, back
  • Index 4 = left, bottom, front
  • Index 5 = right, bottom, front
  • Index 6 = left, top, front
  • Index 7 = right, top, front

void GetCornerVertices OutputIteratorT  it  )  const
 

Returns the 8 corner vertices of this box using the given Vector3 output iterator. The vertices will be inserted in the following order:

  • left, bottom, back
  • right, bottom, back
  • left, top, back
  • right, top, back
  • left, bottom, front
  • right, bottom, front
  • left, top, front
  • right, top, front

Vector3 GetExtents  )  const
 

Returns the box's extents along each axis.

std::pair< size_t, size_t > GetFarPointIndices const Plane plane  )  [static]
 

Returns the indices of the positive and negative far points (in that order) of an axis-aligned box in relation to the given plane. The positive far point is that corner point of the box which occupies the same octant as the plane's normal. The negative far point is the corner point of the exactly opposite octant where the plane's negative normal points to.

The returned indices correspond to the 8 vertices of the box in the following way:

  • Index 0 = left, bottom, back
  • Index 1 = right, bottom, back
  • Index 2 = left, top, back
  • Index 3 = right, top, back
  • Index 4 = left, bottom, front
  • Index 5 = right, bottom, front
  • Index 6 = left, top, front
  • Index 7 = right, top, front

std::pair< Vector3, Vector3 > GetFarPoints const Plane plane  )  const
 

Returns the positive and negative far points (in that order) of this box in relation to the given plane. The positive far point is that corner point of the box which occupies the same octant as the plane's normal. The negative far point is the corner point of the exactly opposite octant where the plane's negative normal points to.

const Vector3 & GetMaxPoint  )  const
 

Returns the maximum point of this box.

const Vector3 & GetMinPoint  )  const
 

Returns the minimum point of this box.

Plane GetPlane size_t  index  )  const
 

Returns one of the 6 planes of this box. The indices correspond to the planes in the following order:

  • Index 0 = left
  • Index 1 = right
  • Index 2 = bottom
  • Index 3 = top
  • Index 4 = back
  • Index 5 = front

The plane normals will point away from the interior of the box. Or in other words, the normals are positive on the outside of the box.

void GetPlanes OutputIteratorT  it  )  const
 

Returns the 6 planes of this box using the given Plane output iterator. The planes will be inserted in the following order:

  • left
  • right
  • bottom
  • top
  • back
  • front

The plane normals will point away from the interior of the box. Or in other words, the normals are positive on the outside of the box.

Rectangle< 3 > GetRectangle size_t  index  )  const
 

Returns one of the 6 rectangles of this box. The indices correspond to the rectangles in the following way:

  • Index 0 = left
  • Index 1 = right
  • Index 2 = bottom
  • Index 3 = top
  • Index 4 = back
  • Index 5 = front

The rectangle normals will point away from the interior of the box. Or in other words, the normals are positive on the outside of the box.

void GetRectangles OutputIteratorT  it  )  const
 

Returns the 6 rectangles that make up this box using the given Recangle<3> output iterator. The rectangles will be inserted in the following order:

  • left
  • right
  • bottom
  • top
  • back
  • front

The rectangle normals will point away from the interior of the box. Or in other words, the normals are positive on the outside of the box.

real GetVolume  )  const [virtual]
 

Returns the volume of this object.

Implements Volume.

void Merge const Sphere sphere  )  [virtual]
 

Grows this volume so that it also contains the given sphere. The function first creates an axis-aligned box that bounds the given sphere and then merges the two axis-aligned boxes.

Implements BoundingVolume.

void Merge const Box box  )  [virtual]
 

Grows this volume so that it also contains the given box. The function first creates an axis-aligned box that bounds the given oriented box and then merges the two axis-aligned boxes.

Implements BoundingVolume.

void Merge const AxisAlignedBox box  )  [virtual]
 

Grows this volume so that it also bounds the given axis-aligned box.

Implements BoundingVolume.

bool operator!= const AxisAlignedBox b  )  const
 

Inequality operator.

bool operator== const AxisAlignedBox b  )  const
 

Equality operator.

void Set const Point< 3 > &  center,
const Vector3 extents
 

Sets this object to represent a new box with the given center point and given extents.

void Set const Vector3 minPoint,
const Vector3 maxPoint
 

Sets the minimum and maximum points of this box.

void SetBound const Frustum frustum  )  [virtual]
 

Sets this volume to bound the given frustum.

Implements BoundingVolume.

void SetBound const Sphere sphere  )  [virtual]
 

Sets this axis-aligned box to bound the given sphere.

Implements BoundingVolume.

void SetBound const Box box  )  [virtual]
 

Sets this axis-aligned box to bound the given box. This is done by determining the eight corner vertices of the given oriented box and then determining the minimum and maximum coordinates along each coordinate axis. This results in a minimum and maximum point that span the axis-aligned box.

Implements BoundingVolume.

void SetBound const AxisAlignedBox box  )  [virtual]
 

Sets this axis-aligned box to bound the given axis-aligned box. In other word, sets this box to the given box.

Implements BoundingVolume.

void SetBound InputIteratorT  itBegin,
InputIteratorT  itEnd
 

Sets this volume so that it bounds all the vertices specified by the given Vector3 iterators.

void SetCenter const Vector3 center  ) 
 

Sets the box's center point. The extents of the box remain the same. Therefore this translates the box to the new center point.

void SetExtents const Vector3 extents  ) 
 

Sets the box's extents along each axis.

void SetMaxPoint const Vector3 maxPoint  ) 
 

Sets the maximum point of this box.

void SetMinPoint const Vector3 minPoint  ) 
 

Sets the minimum point of this box.

void Transform const Math::Transform m  )  [virtual]
 

Transforms this object by the given affine transform.

Reimplemented from GeometricObject3.

void Transform const Matrix4x4 m  )  [virtual]
 

Transforms this object by the given matrix.

Implements GeometricObject3.


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