#include "gtypes.h"

class GPolygon

This class represents a polygon and consists of a vector of the vertices.
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.

Constructor detail


GPolygon();
Creates a GPolygon object with no internal vertices. The vertices must be added using vector operations or the methods addVertex, addEdge, or addPolarEdge.

Usage:

GPolygon poly;

Method detail


void addVertex(GPoint pt);
void addVertex(double x, double y);
Adds a new vertex to the polygon.

Usage:

poly.addVertex(pt);
poly.addVertex(x, y);

void addEdge(double dx, double dy);
Adds a new vertex to the polygon whose coordinates are displaced by dx and dy from the last vertex.

Usage:

poly.addEdge(dx, dy);

void addPolarEdge(double r, double theta);
Adds a new vertex to the polygon whose coordinates are 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);
Returns 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();
Converts the GPolygon to a string.

Usage:

string str = poly.toString();