Box Class Reference

#include <Box.h>

Collaboration diagram for Box:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Box ()
 Box (const Vec3f &minVertex, const Vec3f &maxVertex)
void extend (const Vec3f &a)
void extend (const Box &box)
void clear ()
std::pair< float, float > intersect (const Ray &ray) const
const Vec3fminVertex () const
const Vec3fmaxVertex () const
float area (const SplitPlane &plane) const
std::pair< Box, Boxsplit (const SplitPlane &plane) const
Box clip (const Box &other) const

Private Attributes

Vec3f mMin
 Smallest vertex.
Vec3f mMax
 Biggest vertex.

Detailed Description

Axis aligned bounding box

Author:
Alex Busenius

Christian Engels

Definition at line 16 of file Box.h.


Constructor & Destructor Documentation

Box::Box (  )  [inline]

Default constructor

Definition at line 21 of file Box.h.

References clear().

Referenced by clip(), and split().

Box::Box ( const Vec3f minVertex,
const Vec3f maxVertex 
) [inline]

Constructor with 2 vertices

Parameters:
minVertex Vertex with smallest coordinates
maxVertex Vertex with largest coordinates

Definition at line 31 of file Box.h.


Member Function Documentation

void Box::extend ( const Vec3f a  )  [inline]

Extend the box to contain the given point

Parameters:
a A point to be contained

Definition at line 41 of file Box.h.

References EPSILON, max(), min(), mMax, and mMin.

Referenced by Triangle::calcBounds(), Sphere::calcBounds(), OBJObject::calcBounds(), InfinitePlane::calcBounds(), and extend().

void Box::extend ( const Box box  )  [inline]

Extend the box to contain another box

Parameters:
box A box to be contained

Definition at line 51 of file Box.h.

References EPSILON, extend(), mMax, and mMin.

void Box::clear (  )  [inline]

Reset the box

Definition at line 59 of file Box.h.

References mMax, and mMin.

Referenced by Box(), and OBJObject::calcBounds().

std::pair<float, float> Box::intersect ( const Ray ray  )  const [inline]

Calculate nearest and farest intersection points.

Parameters:
ray The ray to intersect with
Returns:
(INFINITY, -INFINITY) if no intersection has been found, otherwise calculated points

Definition at line 70 of file Box.h.

References Ray::dir(), EPSILON, max(), min(), mMax, mMin, Ray::org(), Vec3f::x(), Vec3f::y(), and Vec3f::z().

Referenced by KDTree::intersect().

const Vec3f& Box::minVertex (  )  const [inline]

Get smallest vertex

Definition at line 113 of file Box.h.

References mMin.

Referenced by OBJObject::calcBounds(), Object::dump(), SAHKDTree::findBestPlane(), SAHKDTree::generateEvents(), and SimpleKDTree::setBestSplit().

const Vec3f& Box::maxVertex (  )  const [inline]

Get biggest vertex

Definition at line 120 of file Box.h.

References mMax.

Referenced by OBJObject::calcBounds(), Object::dump(), SAHKDTree::findBestPlane(), SAHKDTree::generateEvents(), and SimpleKDTree::setBestSplit().

float Box::area ( const SplitPlane plane  )  const [inline]

Calculate surface area of the bounding box if splitting on the given plane. This method returns the relative area of the left child, area of the right child is also 1 - area()

Parameters:
plane Split plane
Returns:
Relative surface area of the left child bounding box

Definition at line 131 of file Box.h.

References mMax, mMin, and NO_AXIS.

Referenced by SAHKDTree::SAH().

std::pair<Box, Box> Box::split ( const SplitPlane plane  )  const [inline]

Split bounding box at given plane

Parameters:
plane Split plane
Returns:
2 resulting boxes

Definition at line 145 of file Box.h.

References Box(), SplitPlane::direction(), EPSILON, mMax, mMin, NO_AXIS, SplitPlane::position(), Vec3f::x(), X_AXIS, Vec3f::y(), Y_AXIS, Vec3f::z(), and Z_AXIS.

Referenced by SAHKDTree::classifyAndSplice().

Box Box::clip ( const Box other  )  const [inline]

Return intersection with given bounding box.

Parameters:
other Other bounding box to clip to

Definition at line 167 of file Box.h.

References Box(), max(), min(), mMax, and mMin.

Referenced by SAHKDTree::generateEvents().


Member Data Documentation

Vec3f Box::mMin [private]

Smallest vertex.

Definition at line 174 of file Box.h.

Referenced by area(), clear(), clip(), extend(), intersect(), minVertex(), and split().

Vec3f Box::mMax [private]

Biggest vertex.

Definition at line 177 of file Box.h.

Referenced by area(), clear(), clip(), extend(), intersect(), maxVertex(), and split().


The documentation for this class was generated from the following file:
Generated on Fri Feb 1 00:02:12 2008 for Grayfall by  doxygen 1.5.1