csPoly2D Class Reference
[Geometry utilities]
The following class represents a general 2D polygon with a bounding box.
More...
#include <poly2d.h>
Public Methods | |
csPoly2D (int start_size=10) | |
Make a new empty polygon. | |
csPoly2D (const csPoly2D ©) | |
Copy constructor. | |
virtual | ~csPoly2D () |
Destructor. | |
csPoly2D & | operator= (const csPoly2D &other) |
Assignment operator. | |
void | MakeEmpty () |
Initialize the polygon to empty. | |
int | GetVertexCount () |
Get the number of vertices. | |
int | GetVertexCount () const |
Get the number of vertices. | |
csVector2 * | GetVertices () |
Get the array with all vertices. | |
const csVector2 * | GetVertices () const |
Get the array with all vertices. | |
csVector2 * | GetVertex (int i) |
Get the specified vertex. | |
csVector2 & | operator[] (int i) |
Get the specified vertex. | |
const csVector2 & | operator[] (int i) const |
Get the specified vertex. | |
csVector2 * | GetFirst () |
Get the first vertex. | |
csVector2 * | GetLast () |
Get the last vertex. | |
bool | In (const csVector2 &v) |
Test if this vector is inside the polygon. | |
void | MakeRoom (int new_max) |
Make room for at least the specified number of vertices. | |
void | SetVertexCount (int n) |
Set the number of vertices. | |
int | AddVertex (const csVector2 &v) |
Add a vertex (2D) to the polygon. | |
int | AddVertex (float x, float y) |
Add a vertex (2D) to the polygon. | |
void | SetVertices (csVector2 const *v, int num) |
Set all polygon vertices at once. | |
void | UpdateBoundingBox () |
Update the bounding box (useful after SetVertices). | |
csBox2 & | GetBoundingBox () |
Get the bounding box (in 2D space) for this polygon. | |
bool | ClipAgainst (iClipper2D *view) |
Clipping routines. | |
void | Intersect (const csPlane2 &plane, csPoly2D &left, csPoly2D &right) const |
Intersect this polygon with a given plane and return the two resulting polygons in left and right. | |
void | ClipPlane (const csPlane2 &plane, csPoly2D &right) const |
This routine is similar to Intersect but it only returns the polygon on the 'right' (positive) side of the plane. | |
void | ExtendConvex (const csPoly2D &other, int this_edge) |
Extend this polygon with another polygon so that the resulting polygon is: (a) still convex, (b) fully contains this polygon, and (c) contains as much as possible of the other polgon. | |
float | GetSignedArea () |
Calculate the signed area of this polygon. | |
void | Random (int num, const csBox2 &max_bbox) |
Generate a random convex polygon with the specified number of vertices. | |
Static Public Methods | |
bool | In (csVector2 *poly, int num_poly, const csVector2 &v) |
Test if a vector is inside the given polygon. | |
Protected Attributes | |
csVector2 * | vertices |
The 2D vertices. | |
csBox2 | bbox |
A 2D bounding box that is maintained automatically. |
Detailed Description
The following class represents a general 2D polygon with a bounding box.
Definition at line 39 of file poly2d.h.
Constructor & Destructor Documentation
|
Make a new empty polygon.
|
|
Copy constructor.
|
|
Destructor.
|
Member Function Documentation
|
Add a vertex (2D) to the polygon. Return index of added vertex. |
|
Add a vertex (2D) to the polygon. Return index of added vertex. Definition at line 159 of file poly2d.h. References csVector2::x, and csVector2::y. |
|
Clipping routines. They return false if the resulting polygon is not visible for some reason. Note that these routines must not be called if the polygon is not visible. These routines will not check that. Note that these routines will put the resulting clipped 2D polygon in place of the original 2D polygon. |
|
This routine is similar to Intersect but it only returns the polygon on the 'right' (positive) side of the plane.
|
|
Extend this polygon with another polygon so that the resulting polygon is: (a) still convex, (b) fully contains this polygon, and (c) contains as much as possible of the other polgon. 'this_edge' is the index of the common edge for this polygon. Edges are indexed with 0 being the edge from 0 to 1 and n-1 being the edge from n-1 to 0. |
|
Get the bounding box (in 2D space) for this polygon.
|
|
Get the first vertex.
|
|
Get the last vertex.
|
|
Calculate the signed area of this polygon.
|
|
Get the specified vertex.
|
|
Get the number of vertices.
|
|
Get the number of vertices.
|
|
Get the array with all vertices.
|
|
Get the array with all vertices.
|
|
Test if a vector is inside the given polygon.
|
|
Test if this vector is inside the polygon.
|
|
Intersect this polygon with a given plane and return the two resulting polygons in left and right. This version is robust. If one of the edges of this polygon happens to be on the same plane as 'plane' then the edge will go to the polygon which already has most edges. i.e. you will not get degenerate polygons. |
|
Initialize the polygon to empty.
|
|
Make room for at least the specified number of vertices.
|
|
Assignment operator.
|
|
Get the specified vertex.
|
|
Get the specified vertex.
|
|
Generate a random convex polygon with the specified number of vertices. The polygon will be inside the given bounding box. @@ Currently only triangles are supported. |
|
Set the number of vertices.
|
|
Set all polygon vertices at once. Copies the array. Note! This doesn't update the bounding box! |
|
Update the bounding box (useful after SetVertices).
|
Member Data Documentation
|
A 2D bounding box that is maintained automatically.
|
|
The 2D vertices.
|
The documentation for this class was generated from the following file:
- csgeom/poly2d.h
Generated for Crystal Space by doxygen 1.2.18