BBox2C
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.
This class is implemented by the system.
Header: | BBox2C.h |
Library: | core.lib |
BBox2C(
|
Initialises the bounds of the box from specified maximum and minimum values.
BBox2C(
|
The copy constructor. Creates a new bounding box with the same values as the argument.
float32 width() const;
|
Width method returns the width of the bounding box. The returned value is absolute width, that is, even the min and max bounds are in wrong order width will return correct result.
float32 height() const;
|
Height method returns the height of the bounding box. The returned value is absolute height, that is, even the min and max bounds are in wrong order height returns correct height.
Vector2C center() const;
|
The center point of the bounding box. The center is calculated as: (min + max) / 2.
Vector2C size() const;
|
Size 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.
bool contains(
|
True if the point is inside the bounding box, else false.
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.
bool contains(
|
True if the specified bounding box is inside the bounding box, else false.
Determines wheter the specified bounding box is inside the bounding box. Both boxes has to be normalized or this method may fail. You may normalize the box by calling the normalize method.
BBox2C trim(
|
The trimmed bounding box.
Trims the bounding box by the specified bounding box and returns the trimmed bounding box. After trimming the bounding box will fit inside the trimming box.
BBox2C normalize() const;
|
The normalized bounding box.
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.
BBox2C offset(
|
The transformed bounding box.
Moves the bounding box by specified offset.
BBox2C combine(
|
The combined bounding box.
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.
const Vector2C& get_min() const;
|
Reference to the minimum of the bounding box.
The return is guaranteed to be valid minimum only if the minimum is known to be correct or method normalize has been called.
const Vector2C& get_max() const;
|
Reference to the maximum of the bounding box.
The return is guaranteed to be valid maximum only if the maximum is known to be correct or method normalize has been called.
void set_min(
|
Sets the minimum of the bounding box.
void set_max(
|
Sets the maximum of the bounding box.
Vector2C& operator[](
|
const Vector2C& operator[](
|
If the specified index is 0 (zero) minimum is returned, else maximum is returned.
This operator 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, the first enables to assign values using this the assignment operator and second is for retrieving the values.
bool operator==(
|
True if both bounding boxes are equal, else false.
This operator compares if both boxes are equal 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.
bool operator!=(
|
True if both bounding boxes are not equal, else false.
This operator compares two boxes and returns true if they are not equal. Both boxes have to be normalized or this method may fail. You may normalize the box by calling the normalize method.
Copyright © 2000 Moppi Productions