#include <PhPolygon.h>
Public Member Functions | |
PhPolygon () | |
Constructor. | |
PhPolygon (PhVector2d a) | |
Constructor. | |
~PhPolygon () | |
Destructor. | |
void | clear () |
Clear. | |
PhVector2d | getPosition () |
Get position. | |
void | setPosition (PhVector2d a) |
Set position. | |
void | pushVertex (PhVector2d a) |
Push vertex. | |
void | pushPoint (PhVector2d a) |
Push point. | |
int | getVertexCount () |
Get vertex count. | |
PhVector2d | getVertex (int a) |
Get vertex. | |
void | setVertex (int a, PhVector2d v) |
Set vertex. | |
float | getRadius () |
Get radius. | |
void | rotate (float rad) |
Rotate. | |
PhVector2d | operator[] (int a) |
Array operator. |
This class represents polygons for collision detection. They can be used for drawing, but there are much easier ways to do that. a polygon is basically any geometric object that can be represented by a triangle fan. the vertices are basically the definitions of the vectors that make up the triangle fan.
phoenix::PhPolygon::PhPolygon | ( | PhVector2d | a | ) |
Constructor.
a | Vector representing the center (position) of the polygon. |
void phoenix::PhPolygon::clear | ( | ) |
Clear.
Removes all the vertices from the polygon.
PhVector2d phoenix::PhPolygon::getPosition | ( | ) |
void phoenix::PhPolygon::setPosition | ( | PhVector2d | a | ) |
Set position.
Sets the center (position) of the polygon. Note that the vertices are relative to the center of the polygon, therefore changing this value will not effect the shape of the polygon.
a | The new center of the polygon. |
void phoenix::PhPolygon::pushVertex | ( | PhVector2d | a | ) |
Push vertex.
Adds a vertex to the polygon. It doesn't care were the polygon is, so PhVector2d(0.0f,10.0f) would push an vector that's 10 units above the polygon's center.
a | Vertex to add. |
void phoenix::PhPolygon::pushPoint | ( | PhVector2d | a | ) |
Push point.
Adds a point to the polygon by making a vertex based on the position of the point and the center point of the polygon. Push point does care about where the polygon is: it takes the vector between our position and where the point is and puts it onto the polygon.
a | Point to add. |
int phoenix::PhPolygon::getVertexCount | ( | ) |
Get vertex count.
PhVector2d phoenix::PhPolygon::getVertex | ( | int | a | ) |
Get vertex.
a | The index of the vertex wanted. |
void phoenix::PhPolygon::setVertex | ( | int | a, | |
PhVector2d | v | |||
) |
Set vertex.
a | The index of the vertex to set. | |
v | What to set it to. |
float phoenix::PhPolygon::getRadius | ( | ) |
Get radius.
void phoenix::PhPolygon::rotate | ( | float | rad | ) |
Rotate.
Rotates the polygon by the given measurement.
rad | Angle measurement in Radians. |
PhVector2d phoenix::PhPolygon::operator[] | ( | int | a | ) | [inline] |
Array operator.
This allows you to treat the polygon like a const array of vectors.
a | The index wanted. |