class GPolygon| Constructor | |
| GPolygon() | Creates a GPolygon object with no internal vertices. |
| Methods | |
| addVertex(pt) addVertex(x, y) | Adds a new vertex to the polygon. |
| addEdge(dx, dy) | Adds a new vertex to the polygon whose coordinates are displaced by dx and dy from the last vertex. |
| addPolarEdge(r, theta) | Adds a new vertex to the polygon whose coordinates are r pixels away from the last point in the direction specified by theta. |
| contains(pt) contains(x, y) | Returns true if the polygon contains the given point, which may be specified either as a point or as distinct coordinates. |
| toString() | Converts the GPolygon to a string. |
GPolygon();
GPolygon object with no internal vertices.
The vertices must be added using vector operations or the methods
addVertex, addEdge, or
addPolarEdge.
Usage:
GPolygon poly;
void addVertex(GPoint pt); void addVertex(double x, double y);
Usage:
poly.addVertex(pt); poly.addVertex(x, y);
void addEdge(double dx, double dy);
dx and dy from the last vertex.
Usage:
poly.addEdge(dx, dy);
void addPolarEdge(double r, double theta);
r
pixels away from the last point in the direction specified by
theta.
Usage:
poly.addPolarEdge(r, theta);
bool contains(GPoint pt); bool contains(double x, double y);
true if the polygon contains the given point,
which may be specified either as a point or as distinct coordinates.
Usage:
if (poly.contains(pt)) . . . if (poly.contains(x, y)) . . .
string toString();
GPolygon to a string.
Usage:
string str = poly.toString();