Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

BoundingBox< N, T > Class Template Reference

Bounding box of a shape; used for coordinate calculations. More...

#include <BoundingBox.h>

Inheritance diagram for BoundingBox< N, T >:

Detailed Description

template<size_t N, typename T = fmat::fmatReal>
class BoundingBox< N, T >

Bounding box of a shape; used for coordinate calculations.

Definition at line 11 of file BoundingBox.h.

List of all members.

Public Member Functions

 BoundingBox ()
 Constructor, defaults to empty bounding box (aka ALL_EXCLUSIVE).
 BoundingBox (T xmin, T ymin, T xmax, T ymax)
 Constructor for 2D boxes.
template<typename R >
 BoundingBox (const BoundingBox< N, R > &bb)
 Conversion between types (same dimensionality).
template<size_t D, typename R >
 BoundingBox (const BoundingBox< D, R > &bb, bool inclusive=true)
 Conversion between type/dimensions.
template<class P >
 BoundingBox (const P &p)
 Constructor for single-point box (note collision requires non-zero area).
template<class P >
 BoundingBox (const P &_min, const P &_max)
 Constructor, specify min/max directly (you are responsible to ensure min << max).
bool empty () const
 Returns true if box has zero or negative area.
void clear ()
 Sets min and max to default values (negative infinite area).
getDimension (size_t x) const
 Return the width of dimenion x (Cowabunga Dude!).
fmat::Column< N, T > getDimensions () const
 Return the width of each dimension.
fmat::Column< N, T > getCenter () const
 Returns the center of the bounding box.
fmat::Column< N, T > getRandom () const
 Returns a random point within the bounding box (including edges).
template<class R >
void expand (const fmat::Column< N, R > &p)
 Expand the bounding box to include p.
template<class R >
void expand (const fmat::SubVector< N, R > &p)
 Expand the bounding box to include p.
template<class P >
void expand (const P &p)
 Expand the bounding box to include p.
void expand (const BoundingBox &bb)
 Expand the bounding box to include bb.
void rotate (fmat::Matrix< N, N > r)
 Applies the specified rotation about the bounding box center, then resets to the axis-aligned boundaries of the rotated bounding box.
void translate (const fmat::Column< N > &x)
 Translates the bounding box, moving the min and max bounds.
void transform (const fmat::Matrix< N, N > &r, const fmat::Column< N > &x)
void recenter (const fmat::Column< N > &c)
 Translates the bounding box, moving the min and max bounds such that the center is placed at c.
template<class P >
bool collides (const P &p) const
 Return true if this box includes p (note edge coincidence does not count).
bool collides (const BoundingBox &bb) const
 Return true if this box intersects p (note edge coincidence does not count).
fmat::Column< N, T > getCorner (size_t x) const
 Returns a corner of the box as determined by which bits are set.
bool operator== (const BoundingBox &bb) const
bool operator!= (const BoundingBox &bb) const

Public Attributes

fmat::Column< N, T > min
 minimum corner
fmat::Column< N, T > max
 maximum corner

Static Public Attributes

static const BoundingBox ALL_INCLUSIVE
 a bounding box initialized to contain everything: (-∞,∞)
static const BoundingBox ALL_EXCLUSIVE
 a bounding box initialized to exclude everything: (∞,-∞) — this is also default construction

Friends

std::ostream & operator<< (std::ostream &out, const BoundingBox &bb)
 For display/serialization.

Constructor & Destructor Documentation

template<size_t N, typename T = fmat::fmatReal>
BoundingBox< N, T >::BoundingBox (  ) 

Constructor, defaults to empty bounding box (aka ALL_EXCLUSIVE).

Using inverted infinities, so no point should collide, and any expansion will collapse to the expansion.

Definition at line 22 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
BoundingBox< N, T >::BoundingBox ( xmin,
ymin,
xmax,
ymax 
)

Constructor for 2D boxes.

Definition at line 27 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
template<typename R >
BoundingBox< N, T >::BoundingBox ( const BoundingBox< N, R > &  bb  ) 

Conversion between types (same dimensionality).

Definition at line 31 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
template<size_t D, typename R >
BoundingBox< N, T >::BoundingBox ( const BoundingBox< D, R > &  bb,
bool  inclusive = true 
) [explicit]

Conversion between type/dimensions.

If inclusive is set and this is an 'upcast' (D < N), extra dimensions will be set to all-inclusive (-∞,∞). Otherwise, extra dimensions will be set to all-exclusive (∞,-∞) and you would need to provide additional expansion in order to form a positive volume.

Definition at line 37 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
template<class P >
BoundingBox< N, T >::BoundingBox ( const P &  p  )  [explicit]

Constructor for single-point box (note collision requires non-zero area).

Definition at line 47 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
template<class P >
BoundingBox< N, T >::BoundingBox ( const P &  _min,
const P &  _max 
) [explicit]

Constructor, specify min/max directly (you are responsible to ensure min << max).

Definition at line 50 of file BoundingBox.h.


Member Function Documentation

template<size_t N, typename T = fmat::fmatReal>
void BoundingBox< N, T >::clear (  ) 

Sets min and max to default values (negative infinite area).

Definition at line 56 of file BoundingBox.h.

Referenced by LinkComponent::computeOwnAABB().

template<size_t N, typename T = fmat::fmatReal>
bool BoundingBox< N, T >::collides ( const BoundingBox< N, T > &  bb  )  const

Return true if this box intersects p (note edge coincidence does not count).

Definition at line 146 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
template<class P >
bool BoundingBox< N, T >::collides ( const P &  p  )  const

Return true if this box includes p (note edge coincidence does not count).

Definition at line 141 of file BoundingBox.h.

Referenced by HierarchicalObstacle::collides(), and RectangularObstacle::collides().

template<size_t N, typename T = fmat::fmatReal>
bool BoundingBox< N, T >::empty (  )  const

Returns true if box has zero or negative area.

Definition at line 53 of file BoundingBox.h.

Referenced by LinkComponent::getBB2D(), and LinkComponent::getBB3D().

template<size_t N, typename T = fmat::fmatReal>
void BoundingBox< N, T >::expand ( const BoundingBox< N, T > &  bb  ) 

Expand the bounding box to include bb.

Definition at line 99 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
template<class P >
void BoundingBox< N, T >::expand ( const P &  p  ) 

Expand the bounding box to include p.

This version picks up extended-dimenion points, arrays, and column subclasses, converting to a SubVector intermediary. Allows implicit truncation of 3D to 2D, since this is pretty commonly used in DualCoding.

Definition at line 93 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
template<class R >
void BoundingBox< N, T >::expand ( const fmat::SubVector< N, R > &  p  ) 

Expand the bounding box to include p.

This picks up subvectors of the correct size

Definition at line 88 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
template<class R >
void BoundingBox< N, T >::expand ( const fmat::Column< N, R > &  p  ) 
template<size_t N, typename T = fmat::fmatReal>
fmat::Column<N,T> BoundingBox< N, T >::getCenter (  )  const
template<size_t N, typename T = fmat::fmatReal>
fmat::Column<N,T> BoundingBox< N, T >::getCorner ( size_t  x  )  const

Returns a corner of the box as determined by which bits are set.

The ith bit corresponds to the ith axis, 0 returns lower bound, and 1 returns upper bound

Definition at line 160 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
T BoundingBox< N, T >::getDimension ( size_t  x  )  const

Return the width of dimenion x (Cowabunga Dude!).

Definition at line 59 of file BoundingBox.h.

Referenced by Draw::setRegion().

template<size_t N, typename T = fmat::fmatReal>
fmat::Column<N,T> BoundingBox< N, T >::getDimensions (  )  const
template<size_t N, typename T = fmat::fmatReal>
fmat::Column<N,T> BoundingBox< N, T >::getRandom (  )  const

Returns a random point within the bounding box (including edges).

Definition at line 68 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
bool BoundingBox< N, T >::operator!= ( const BoundingBox< N, T > &  bb  )  const

Definition at line 185 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
bool BoundingBox< N, T >::operator== ( const BoundingBox< N, T > &  bb  )  const

Definition at line 182 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
void BoundingBox< N, T >::recenter ( const fmat::Column< N > &  c  ) 

Translates the bounding box, moving the min and max bounds such that the center is placed at c.

Definition at line 134 of file BoundingBox.h.

Referenced by BoundingBox< 3 >::transform().

template<size_t N, typename T = fmat::fmatReal>
void BoundingBox< N, T >::rotate ( fmat::Matrix< N, N >  r  ) 

Applies the specified rotation about the bounding box center, then resets to the axis-aligned boundaries of the rotated bounding box.

This does not handle bounding boxes with infinite bounds.

Definition at line 106 of file BoundingBox.h.

Referenced by BoundingBox< 3 >::transform().

template<size_t N, typename T = fmat::fmatReal>
void BoundingBox< N, T >::transform ( const fmat::Matrix< N, N > &  r,
const fmat::Column< N > &  x 
)

Definition at line 128 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
void BoundingBox< N, T >::translate ( const fmat::Column< N > &  x  ) 

Translates the bounding box, moving the min and max bounds.

Definition at line 123 of file BoundingBox.h.


Friends And Related Function Documentation

template<size_t N, typename T = fmat::fmatReal>
std::ostream& operator<< ( std::ostream &  out,
const BoundingBox< N, T > &  bb 
) [friend]

For display/serialization.

Definition at line 171 of file BoundingBox.h.


Member Data Documentation

template<size_t N, typename T = fmat::fmatReal>
const BoundingBox< N, T > BoundingBox< N, T >::ALL_EXCLUSIVE [static]

a bounding box initialized to exclude everything: (∞,-∞) — this is also default construction

Definition at line 14 of file BoundingBox.h.

template<size_t N, typename T = fmat::fmatReal>
const BoundingBox< N, T > BoundingBox< N, T >::ALL_INCLUSIVE [static]

a bounding box initialized to contain everything: (-∞,∞)

Definition at line 13 of file BoundingBox.h.


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:05 2016 by Doxygen 1.6.3