AABB Class Reference

2D Axis Aligned Bounding Box. More...

#include <Math/MathCommon.h>

List of all members.

Public Member Functions

 AABB ()
 Default constructor.
 AABB (const Point2f &MIN, const Point2f &MAX)
 Constructs a specific AABB.
 AABB (float minx, float miny, float maxx, float maxy)
 Constructs a specific AABB.
 AABB (const Point2f &center, float w, float h)
 Constructs a specific AABB.
Rectf ToRect () const
 Converts the AABB to a Rect.
float Width () const
 Computes the width of the AABB.
float Height () const
 Computes the height of the AABB.
float Area () const
 Computes the area of the AABB.
Point2f CenterPosition () const
 Computes the center position of the AABB.
void Extends (float &halfWidth, float &halfHeight) const
 Gets the half width and height.
bool Overlap (const AABB &b2) const
 Determines if the given AABB overlaps with this AABB.
bool Overlap (const Circle &c) const
 Determines if the given Circle overlaps with this AABB.
int Intersect (const Line &l, float &enterTime, float &exitTime) const
 Intersects the given Lines with this AABB.
int Intersect (const Ray &r, float &enterTime, float &exitTime) const
 Intersects the given Ray with this AABB.
bool Inside (const Point2f &p) const
 Determines if the given point is inside the AABB.
Point2f ClosestPoint (const Point2f &p) const
 Computes a point on the AABB closes to the given point.
Vector2f GetClosestNormal (const Point2f &p) const
 Determines the surface of the AABB closest to the given point and returns the normal vector of that surface.
float SquaredDistanceTo (const Point2f &p) const
 Computes the squared distance between the given point and the closest point on the AABB.

Public Attributes

Point2f min
Point2f max

Detailed Description

2D Axis Aligned Bounding Box.


Constructor & Destructor Documentation

AABB::AABB ( const Point2f MIN,
const Point2f MAX 
) [inline]

Constructs a specific AABB.

Parameters:
[in] MIN the min position of the AABB.
[in] MAX the max position of the AABB.
AABB::AABB ( float  minx,
float  miny,
float  maxx,
float  maxy 
) [inline]

Constructs a specific AABB.

Parameters:
[in] minx the x value of the min position of the AABB.
[in] miny the y value of the min position of the AABB.
[in] maxx the x value of the max position of the AABB.
[in] maxy the y value of the max position of the AABB.
AABB::AABB ( const Point2f center,
float  w,
float  h 
) [inline]

Constructs a specific AABB.

Parameters:
[in] center the center position of the AABB.
[in] w the width of the AABB.
[in] h the height of the AABB.

Member Function Documentation

float AABB::Area (  )  const [inline]

Computes the area of the AABB.

Returns:
the area.
Point2f AABB::CenterPosition (  )  const

Computes the center position of the AABB.

Returns:
The center position of the AABB.
Point2f AABB::ClosestPoint ( const Point2f p  )  const

Computes a point on the AABB closes to the given point.

Parameters:
[in] p the point.
Returns:
A point on this AABB closes to p.

pg 130

void AABB::Extends ( float &  halfWidth,
float &  halfHeight 
) const

Gets the half width and height.

Parameters:
[out] halfWidth the half width.
[out] halfHeight the half height.
Vector2f AABB::GetClosestNormal ( const Point2f p  )  const

Determines the surface of the AABB closest to the given point and returns the normal vector of that surface.

Parameters:
[in] p the point.
Returns:
The normal of the surface closest to the point p.
float AABB::Height (  )  const

Computes the height of the AABB.

Returns:
The height of the AABB.
bool AABB::Inside ( const Point2f p  )  const

Determines if the given point is inside the AABB.

Parameters:
[in] p the point to check against.
Returns:
True if p is inside the AABB. False is p is outside the AABB.
int AABB::Intersect ( const Ray r,
float &  enterTime,
float &  exitTime 
) const

Intersects the given Ray with this AABB.

Parameters:
[in] r The Ray to intersect against.
[out] enterTime the time the ray enters the AABB. Only valid when 1 or 2 is returned.
[out] exitTime the time the ray exits the AABB. Only valid when 1 or 2 is returned.
Returns:
The number of intersection points with this AABB, either 0, 1 or 2. When 0 is returned there was no intersection and enterTime and exitTime are undifined. When 1 is returned there is one intersection and enterTime will be equal to exitTime. When 2 is returned there are two points of intersection and enterTime is strictly less then exit time.

pg 181

int AABB::Intersect ( const Line l,
float &  enterTime,
float &  exitTime 
) const

Intersects the given Lines with this AABB.

Parameters:
[in] l The line to intersect against.
[out] enterTime the time the ray enters the AABB. Only valid when 1 or 2 is returned.
[out] exitTime the time the ray exits the AABB. Only valid when 1 or 2 is returned.
Returns:
The number of intersection points with this AABB, either 0, 1 or 2. When 0 is returned there was no intersection and enterTime and exitTime are undifined. When 1 is returned there is one intersection and enterTime will be equal to exitTime. When 2 is returned there are two points of intersection and enterTime is strictly less then exit time.
bool AABB::Overlap ( const Circle &  c  )  const

Determines if the given Circle overlaps with this AABB.

Parameters:
[in] c the circle to check for overlap against.
Returns:
True if c overlaps this AABB. False if there is no overlap.
bool AABB::Overlap ( const AABB b2  )  const

Determines if the given AABB overlaps with this AABB.

Parameters:
[in] b2 the AABB to check for overlap against.
Returns:
True if b2 overlaps this AABB. False if there is no overlap.
float AABB::SquaredDistanceTo ( const Point2f p  )  const

Computes the squared distance between the given point and the closest point on the AABB.

Parameters:
[in] the point.
Returns:
The squared distacne between p and the closest point to p on the AABB.

pg 131

Rectf AABB::ToRect (  )  const

Converts the AABB to a Rect.

Returns:
The Rectf from of the AABB.
float AABB::Width (  )  const

Computes the width of the AABB.

Returns:
The width of the AABB.

Member Data Documentation

Top right corner of the bounding box.

Bottom left corner of the bounding box.


The documentation for this class was generated from the following files:
Generated on Mon Apr 5 19:08:05 2010 for BrickOut |ReDuX| by  doxygen 1.6.3