Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

BBox2C Class Reference

Bounding box class. More...

#include <BBox2C.h>

List of all members.

Public Methods

 BBox2C ()
 Default constructor.

 BBox2C (const Vector2C &rMin, const Vector2C &rMax)
 Initialises the bounds of the box from specified maximum and minimum values.

 BBox2C (const BBox2C &rBBox)
 Copy constructor.

virtual ~BBox2C ()
 Destructor.

float32 width () const
 Returns the width of the bounding box.

float32 height () const
 Returns the height of the bounding box.

Vector2C center () const
 Returns the center of the bounding box.

Vector2C size () const
 Returns the size of the bounding box.

bool contains (const Vector2C &rVec) const
 Determines wheter the specified point is inside the bounding box.

bool contains (const BBox2C &rBBox) const
 Determines wheter the specified bounding box is inside the bounding box.

BBox2C trim (const BBox2C &rBBox) const
 Trims the bounding box by the specified bounding box.

BBox2C normalize () const
 Normalizes the bounding box so that the minimum and maximum values are correct.

BBox2C offset (const Vector2C &rOffset) const
 Moves the bounding box by specified offset.

BBox2C combine (const BBox2C &rBBox) const
 Combines two bounding boxes.

Vector2Coperator[] (int i)
 Returns either minimum or maximum of the box.

const Vector2Coperator[] (int i) const
 Returns either minimum or maximum of the box.

bool operator== (const BBox2C &rBBox) const
 Compares two boxes and returns true if they are equal.

bool operator!= (const BBox2C &rBBox) const
 Compares two boxes and returns true if they are non-equal.


Detailed Description

Bounding box class.

BBox2C class implements two dimensional box used as bounding box. When specifying a bounding box you must be careful to construct it so that it is normalized. In other words, the minimum values and maximum values has to be correct. If the bounding box is not normalized many methods will return incorrect results. If a method needs the box ot be normalized it is mentioned. To normalize non-normalized bounding box use the normalize method.

See also:
normalize
This class is implemented by the system.


Constructor & Destructor Documentation

BBox2C  
 

Default constructor.

BBox2C const Vector2C   rMin,
const Vector2C   rMax
 

Initialises the bounds of the box from specified maximum and minimum values.

BBox2C const BBox2C &    rBBox
 

Copy constructor.

virtual ~BBox2C   [virtual]
 

Destructor.


Member Function Documentation

Vector2C center   const [inline]
 

Returns the center of the bounding box.

Returns :
The center point of the bounding box. The center is calculated as: (min + max) / 2.

BBox2C combine const BBox2C &    rBBox const
 

Combines two bounding boxes.

Makes the dimension of a bounding box equal to the union of the bounding box and the other specified bounding box, and returns the union. The union is the smallest bounding box containing both bounding boxes.

Returns :
The combined bounding box.

bool contains const BBox2C &    rBBox const [inline]
 

Determines wheter the specified bounding box is inside the bounding box.

Both boxes have to be normalized or this method may fail. You may normalize the box by calling the normalize() method.

Returns :
True if the specified bounding box is inside the bounding box, else false.

bool contains const Vector2C   rVec const [inline]
 

Determines wheter the specified point is inside the bounding box.

The box has to be normalized or this method may fail. You may normalize the box by calling the normalize() method.

Returns :
True if the point is inside the bounding box, else false.

float32 height   const [inline]
 

Returns the height of the bounding box.

Returns :
The returned value is absolute height, that is, even the min and max bounds are in wrong order height() will return correct result.

BBox2C normalize   const
 

Normalizes the bounding box so that the minimum and maximum values are correct.

This method is useful when dealing with bounding boxes which may be inverted.

Returns :
The normalized bounding box.

BBox2C offset const Vector2C   rOffset const [inline]
 

Moves the bounding box by specified offset.

Returns :
The transformed bounding box.

bool operator!= const BBox2C &    rBBox const [inline]
 

Compares two boxes and returns true if they are non-equal.

Both boxes have to be normalized or this method may fail. You may normalize the box by calling the normalize() method.

Returns :
True if both bounding boxes are non-equal, else false.

bool operator== const BBox2C &    rBBox const [inline]
 

Compares two boxes and returns true if they are equal.

Both boxes have to be normalized or this method may fail. You may normalize the box by calling the normalize() method.

Returns :
True if both bounding boxes are equal, else false.

const Vector2C & operator[] int    i const [inline]
 

Returns either minimum or maximum of the box.

The returns value depends on the given index: 0 for minimum, 1 for maximum. The box has to be normalized or this method may return incorrect values. You may normalize the box by calling the normalize()> method. There are two versions of this method, this version is for retrieving the values.

Returns :
If the specified index is 0 (zero) minimum is returned, else maximum is returned.

Vector2C & operator[] int    i [inline]
 

Returns either minimum or maximum of the box.

The returns value depends on the given index: 0 for minimum, 1 for maximum. The box has to be normalized or this method may return incorrect values. You may normalize the box by calling the normalize() method. There are two versions of this method, this version enables to assign values using the assignment operator.

Returns :
If the specified index is 0 (zero) minimum is returned, else maximum is returned.

Vector2C size   const [inline]
 

Returns the size of the bounding box.

Returns :
The size of the bounding box. Size is calculated as: max - min. You must normalize the bounding box to get correct size. You may normalize the box by calling the normalize() method.

BBox2C trim const BBox2C &    rBBox const
 

Trims the bounding box by the specified bounding box.

After trimming the bounding box will fit inside the trimming box.

Parameters:
rBBox  Reference to the trimming box.
Returns :
The trimmed bounding box.

float32 width   const [inline]
 

Returns the width of the bounding box.

Returns :
The returned value is absolute width, that is, even the min and max bounds are in wrong order width() will return correct result.


Moppi Demopaja SDK Documentation -- Copyright © 2000-2002 Moppi Productions