![]() |
Public API Reference |
#include <box.h>
Public Methods | |
float | MinX () const |
Get the minimum X value of the box. More... | |
float | MinY () const |
Get the minimum Y value of the box. More... | |
float | MaxX () const |
Get the maximum X value of the box. More... | |
float | MaxY () const |
Get the maximum Y value of the box. More... | |
float | Min (int idx) const |
Get Min component for 0 (x) or 1 (y). More... | |
float | Max (int idx) const |
Get Max component for 0 (x) or 1 (y). More... | |
const csVector2 & | Min () const |
Get the 2d vector of minimum (x, y) values. More... | |
const csVector2 & | Max () const |
Get the 2d vector of maximum (x, y) values. More... | |
csVector2 | GetCorner (int corner) const |
Return every corner of this bounding box from 0 to 3. More... | |
csVector2 | GetCenter () const |
Get the center of this box. More... | |
void | SetCenter (const csVector2 &c) |
Set the center of this box. More... | |
void | SetSize (const csVector2 &s) |
Set the size of the box but keep the center intact. More... | |
void | GetEdgeInfo (int edge, int &v1, int &v2) const |
Given an edge index (CS_BOX_EDGE_xy_Xy etc.) return the two vertices (index CS_BOX_CORNER_xy etc.). More... | |
csSegment2 | GetEdge (int edge) const |
Return every edge (segment) of this bounding box from 0 to 7 (CS_BOX_EDGE_xy_Xy etc.). More... | |
void | GetEdge (int edge, csSegment2 &e) const |
Return every edge (segment) of this bounding box from 0 to 7 (CS_BOX_EDGE_xy_Xy etc.). More... | |
bool | Intersect (csVector2 *poly, int num_poly) const |
Test if a polygon if visible in the box. More... | |
bool | In (float x, float y) const |
Test if the given coordinate is in this box. More... | |
bool | In (const csVector2 &v) const |
Test if the given coordinate is in this box. More... | |
bool | Overlap (const csBox2 &box) const |
Test if this box overlaps with the given box. More... | |
bool | Contains (const csBox2 &box) const |
Test if this box contains the other box. More... | |
bool | Empty () const |
Test if this box is empty. More... | |
float | SquaredOriginDist () const |
Calculate the squared distance between (0,0) and the box This routine is extremely efficient. More... | |
float | SquaredOriginMaxDist () const |
Calculate the squared distance between (0,0) and the point on the box which is furthest away from (0,0). More... | |
void | StartBoundingBox () |
Initialize this box to empty. More... | |
void | StartBoundingBox (const csVector2 &v) |
Initialize this box to one vertex. More... | |
void | StartBoundingBox (float x, float y) |
Same but given some coordinates. More... | |
void | AddBoundingVertex (float x, float y) |
Add a new vertex and recalculate the bounding box. More... | |
void | AddBoundingVertex (const csVector2 &v) |
Add a new vertex and recalculate the bounding box. More... | |
void | AddBoundingVertexSmart (float x, float y) |
Add a new vertex and recalculate the bounding box. More... | |
void | AddBoundingVertexSmart (const csVector2 &v) |
Add a new vertex and recalculate the bounding box. More... | |
csBox2 () | |
Initialize this box to empty. More... | |
csBox2 (const csVector2 &v) | |
Initialize this box with one point. More... | |
csBox2 (float x1, float y1, float x2, float y2) | |
Initialize this box with the given values. More... | |
void | Set (const csVector2 &bmin, const csVector2 &bmax) |
Sets the bounds of the box with the given values. More... | |
void | Set (float x1, float y1, float x2, float y2) |
Sets the bounds of the box with the given values. More... | |
void | SetMin (int idx, float val) |
Set Min component for 0 (x) or 1 (y). More... | |
void | SetMax (int idx, float val) |
Set Max component for 0 (x) or 1 (y). More... | |
csBox2 & | operator+= (const csBox2 &box) |
Compute the union of two bounding boxes. More... | |
csBox2 & | operator+= (const csVector2 &point) |
Compute the union of a point with this bounding box. More... | |
csBox2 & | operator *= (const csBox2 &box) |
Compute the intersection of two bounding boxes. More... | |
bool | TestIntersect (const csBox2 &box) const |
Test if the two boxes have an intersection. More... | |
Static Public Methods | |
bool | Intersect (float minx, float miny, float maxx, float maxy, csVector2 *poly, int num_poly) |
Test if a polygon if visible in the box. More... | |
bool | Intersect (const csVector2 &minbox, const csVector2 &maxbox, csVector2 *poly, int num_poly) |
Test if a polygon if visible in the box. More... | |
Protected Attributes | |
csVector2 | minbox |
The top-left coordinate of the bounding box. More... | |
csVector2 | maxbox |
The bottom-right coordinate of the bounding box. More... | |
Friends | |
csBox2 | operator+ (const csBox2 &box1, const csBox2 &box2) |
Compute the union of two bounding boxes. More... | |
csBox2 | operator+ (const csBox2 &box, const csVector2 &point) |
Compute the union of a bounding box and a point. More... | |
csBox2 | operator * (const csBox2 &box1, const csBox2 &box2) |
Compute the intersection of two bounding boxes. More... | |
bool | operator== (const csBox2 &box1, const csBox2 &box2) |
Tests if two bounding boxes are equal. More... | |
bool | operator!= (const csBox2 &box1, const csBox2 &box2) |
Tests if two bounding boxes are unequal. More... | |
bool | operator< (const csBox2 &box1, const csBox2 &box2) |
Tests if box1 is a subset of box2. More... | |
bool | operator> (const csBox2 &box1, const csBox2 &box2) |
Tests if box1 is a superset of box2. More... | |
bool | operator< (const csVector2 &point, const csBox2 &box) |
Tests if a point is contained in a box. More... |
In order to operate correctly, this bounding box assumes that all values entered or compared against lie within the range (-CS_BOUNDINGBOX_MAXVALUE, CS_BOUNDINGBOX_MAXVALUE). It is not recommended to use points outside of this range.
Definition at line 86 of file box.h.
|
Initialize this box to empty.
Definition at line 327 of file box.h. References CS_BOUNDINGBOX_MAXVALUE. |
|
Initialize this box with one point.
|
|
Initialize this box with the given values.
Definition at line 334 of file box.h. References Empty, and StartBoundingBox. |
|
Add a new vertex and recalculate the bounding box.
Definition at line 286 of file box.h. References AddBoundingVertex, csVector2::x, and csVector2::y. |
|
Add a new vertex and recalculate the bounding box.
Definition at line 279 of file box.h. References csVector2::x, and csVector2::y. Referenced by AddBoundingVertex. |
|
Add a new vertex and recalculate the bounding box. This version is a little more optimal. It assumes however that at least one point has been added to the bounding box. Definition at line 307 of file box.h. References AddBoundingVertexSmart, csVector2::x, and csVector2::y. |
|
Add a new vertex and recalculate the bounding box. This version is a little more optimal. It assumes however that at least one point has been added to the bounding box. Definition at line 296 of file box.h. References csVector2::x, and csVector2::y. Referenced by AddBoundingVertexSmart. |
|
Test if this box contains the other box.
Definition at line 230 of file box.h. References maxbox, minbox, csVector2::x, and csVector2::y. |
|
Test if this box is empty.
Definition at line 237 of file box.h. References csVector2::x, and csVector2::y. Referenced by csBox2. |
|
Get the center of this box.
|
|
Return every corner of this bounding box from 0 to 3. This contrasts with Min() and Max() because those are only the min and max corners. Corner 0 = xy, 1 = xY, 2 = Xy, 3 = XY. Use CS_BOX_CORNER_xy etc. defines. |
|
Return every edge (segment) of this bounding box from 0 to 7 (CS_BOX_EDGE_xy_Xy etc.).
Definition at line 169 of file box.h. References csSegment2::SetEnd, and csSegment2::SetStart. |
|
Return every edge (segment) of this bounding box from 0 to 7 (CS_BOX_EDGE_xy_Xy etc.).
|
|
Given an edge index (CS_BOX_EDGE_xy_Xy etc.) return the two vertices (index CS_BOX_CORNER_xy etc.).
|
|
Test if the given coordinate is in this box.
Definition at line 216 of file box.h. References In, csVector2::x, and csVector2::y. |
|
Test if the given coordinate is in this box.
Definition at line 208 of file box.h. References csVector2::x, and csVector2::y. Referenced by In, and csBoxClipper::IsInside. |
|
Test if a polygon if visible in the box. This function does not test the case where the box is fully contained in the polygon. But all other cases are tested. Definition at line 202 of file box.h. References Intersect. |
|
Test if a polygon if visible in the box. This function does not test the case where the box is fully contained in the polygon. But all other cases are tested. Definition at line 190 of file box.h. References Intersect, csVector2::x, and csVector2::y. |
|
Test if a polygon if visible in the box. This function does not test the case where the box is fully contained in the polygon. But all other cases are tested. Referenced by Intersect. |
|
Get the 2d vector of maximum (x, y) values.
|
|
Get Max component for 0 (x) or 1 (y).
Definition at line 115 of file box.h. References csVector2::x, and csVector2::y. |
|
Get the maximum X value of the box.
Definition at line 109 of file box.h. References csVector2::x. |
|
Get the maximum Y value of the box.
Definition at line 111 of file box.h. References csVector2::y. |
|
Get the 2d vector of minimum (x, y) values.
|
|
Get Min component for 0 (x) or 1 (y).
Definition at line 113 of file box.h. References csVector2::x, and csVector2::y. |
|
Get the minimum X value of the box.
Definition at line 105 of file box.h. References csVector2::x. |
|
Get the minimum Y value of the box.
Definition at line 107 of file box.h. References csVector2::y. |
|
Compute the intersection of two bounding boxes.
|
|
Compute the union of a point with this bounding box.
|
|
Compute the union of two bounding boxes.
|
|
Test if this box overlaps with the given box.
Definition at line 222 of file box.h. References maxbox, minbox, csVector2::x, and csVector2::y. |
|
Sets the bounds of the box with the given values.
Definition at line 346 of file box.h. References StartBoundingBox, csVector2::x, and csVector2::y. |
|
Sets the bounds of the box with the given values.
|
|
Set the center of this box. This will not change the size of the box but just relocate the center. |
|
Set Max component for 0 (x) or 1 (y).
Definition at line 360 of file box.h. References csVector2::x, and csVector2::y. |
|
Set Min component for 0 (x) or 1 (y).
Definition at line 353 of file box.h. References csVector2::x, and csVector2::y. |
|
Set the size of the box but keep the center intact.
|
|
Calculate the squared distance between (0,0) and the box This routine is extremely efficient.
|
|
Calculate the squared distance between (0,0) and the point on the box which is furthest away from (0,0). This routine is extremely efficient. |
|
Same but given some coordinates.
Definition at line 272 of file box.h. References csVector2::x, and csVector2::y. |
|
Initialize this box to one vertex.
|
|
Initialize this box to empty.
Definition at line 258 of file box.h. References CS_BOUNDINGBOX_MAXVALUE, csVector2::x, and csVector2::y. |
|
Test if the two boxes have an intersection.
|
|
Compute the intersection of two bounding boxes.
|
|
Tests if two bounding boxes are unequal.
|
|
Compute the union of a bounding box and a point.
|
|
Compute the union of two bounding boxes.
|
|
Tests if a point is contained in a box.
|
|
Tests if box1 is a subset of box2.
|
|
Tests if two bounding boxes are equal.
|
|
Tests if box1 is a superset of box2.
|
|
The bottom-right coordinate of the bounding box.
|
|
The top-left coordinate of the bounding box.
|