phoenix::PhPolygon Class Reference

Polygon class. More...

#include <PhPolygon.h>

List of all members.

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.


Detailed Description

Polygon class.

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.

See also:
phoenix::PhPolygonCollisionHandler

Constructor & Destructor Documentation

phoenix::PhPolygon::PhPolygon ( PhVector2d  a  ) 

Constructor.

Parameters:
a Vector representing the center (position) of the polygon.


Member Function Documentation

void phoenix::PhPolygon::clear (  ) 

Clear.

Removes all the vertices from the polygon.

PhVector2d phoenix::PhPolygon::getPosition (  ) 

Get position.

Returns:
The center of the polygon (The position).
See also:
setPosition()

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.

Parameters:
a The new center of the polygon.
See also:
getPosition()

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.

Parameters:
a Vertex to add.
See also:
pushPoint()

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.

Parameters:
a Point to add.
See also:
pushVertex()

int phoenix::PhPolygon::getVertexCount (  ) 

Get vertex count.

Returns:
The current number of vertices in the polygon.

PhVector2d phoenix::PhPolygon::getVertex ( int  a  ) 

Get vertex.

Parameters:
a The index of the vertex wanted.
Returns:
The vertex at index a.

void phoenix::PhPolygon::setVertex ( int  a,
PhVector2d  v 
)

Set vertex.

Parameters:
a The index of the vertex to set.
v What to set it to.

float phoenix::PhPolygon::getRadius (  ) 

Get radius.

Returns:
The magnitude of the largest vertex in the polygon.

void phoenix::PhPolygon::rotate ( float  rad  ) 

Rotate.

Rotates the polygon by the given measurement.

Parameters:
rad Angle measurement in Radians.
Todo:
This is slow, use rotation matrices or atleast do something to speed it up.

PhVector2d phoenix::PhPolygon::operator[] ( int  a  )  [inline]

Array operator.

This allows you to treat the polygon like a const array of vectors.

Parameters:
a The index wanted.
Returns:
A vector representing the vertex at the given index.


The documentation for this class was generated from the following file:
Generated on Tue Nov 20 21:59:24 2007 for Phoenix by  doxygen 1.5.4