Otter  0.9.8.91
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.Polygon Class Reference

Class representing a Polygon. More...

Public Member Functions

 Polygon (Vector2 firstPoint, params Vector2[] points)
 Create a new Polygon. More...
 
 Polygon (Polygon copy)
 Create a new Polygon. More...
 
 Polygon (params float[] points)
 Create a new Polygon. More...
 
List< Line2GetEdgesAsLines ()
 Get a list of all the edges of the Polygon as Line2 objects. More...
 
override string ToString ()
 Convert to a string. More...
 
void OffsetPoints (Vector2 vector)
 Offset all the points by a Vector2 amount. More...
 
void Rotate (float amount, float aroundX, float aroundY)
 Rotate the polygon by a specified amount. More...
 
void Scale (float amountX, float amountY, float aroundX, float aroundY)
 Scale the polygon by a specified amount. More...
 
void Clear ()
 Clear all points. More...
 
void OffsetPoints (float x, float y)
 Offset all the points by a Vector2 amount. More...
 
bool ContainsPoint (Vector2 point)
 Check to see if a Polygon contains a point. More...
 
bool ContainsPoint (float x, float y)
 Check to see if a Polygon contains a point. More...
 
void Add (Vector2 point)
 Add a Vector2 to the list of points. More...
 
void Add (float x, float y)
 Add an X Y position to the list of points. More...
 
Range Projection (Vector2 axis)
 Project the polygon onto an axis. More...
 
List< Vector2GetAxes ()
 Get the axes to project on. More...
 
bool Overlap (Polygon other)
 Test another Polygon for an overlap. Will not work if either Polygon is concave! More...
 

Static Public Member Functions

static Polygon CreateCircle (float radius, int steps=32)
 Creates a Polygon in the shape of a circle. More...
 
static Polygon CreateRectangle (float width, float height)
 Creates a Polygon in the shape of a rectangle. More...
 

Properties

List< Vector2Points [get, set]
 The list of Vector2 points. More...
 
int Count [get]
 The number of points in the Polygon. More...
 
float Width [get]
 The Width of the polygon determined by the right most point minus the left most point. More...
 
float Height [get]
 The Height of the polygon determined by the bottom most point minus the top most point. More...
 
float HalfWidth [get]
 Half of the Width. More...
 
float HalfHeight [get]
 Half of the Height. More...
 
float Left [get]
 
float Right [get]
 
float Top [get]
 
float Bottom [get]
 
Vector2 this[int index] [get, set]
 The list of Vector2 points in the Polygon. More...
 

Detailed Description

Class representing a Polygon.

Constructor & Destructor Documentation

Otter.Polygon.Polygon ( Vector2  firstPoint,
params Vector2[]  points 
)

Create a new Polygon.

Parameters
pointsThe Vector2 points composing the Polygon.
Otter.Polygon.Polygon ( Polygon  copy)

Create a new Polygon.

Parameters
copyThe source Polygon to copy.
Otter.Polygon.Polygon ( params float[]  points)

Create a new Polygon.

Parameters
pointsA series of points to create the Polygon from (x1, y1, x2, y2, x3, y3...)

Member Function Documentation

void Otter.Polygon.Add ( Vector2  point)

Add a Vector2 to the list of points.

Parameters
pointThe Vector2 to add the points.
void Otter.Polygon.Add ( float  x,
float  y 
)

Add an X Y position to the list of points.

Parameters
xThe X position to add.
yThe Y position to add.
void Otter.Polygon.Clear ( )

Clear all points.

bool Otter.Polygon.ContainsPoint ( Vector2  point)

Check to see if a Polygon contains a point.

Parameters
pointThe point to check for.
Returns
True if the polygon contains the point.
bool Otter.Polygon.ContainsPoint ( float  x,
float  y 
)

Check to see if a Polygon contains a point.

Parameters
xThe X position of the point to check for.
yThe Y position of the point to check for.
Returns
True if the polygon contains the point.
static Polygon Otter.Polygon.CreateCircle ( float  radius,
int  steps = 32 
)
static

Creates a Polygon in the shape of a circle.

Parameters
radiusThe radius of the circle.
stepsHow many steps to use to create the circle (higher is rounder.)
Returns
A circle shaped Polygon.
static Polygon Otter.Polygon.CreateRectangle ( float  width,
float  height 
)
static

Creates a Polygon in the shape of a rectangle.

Parameters
widthThe width of the rectangle.
heightThe height of the rectangle.
Returns
A rectangle shaped Polygon.
List<Vector2> Otter.Polygon.GetAxes ( )

Get the axes to project on.

Returns
A list of normals from the polygon.
List<Line2> Otter.Polygon.GetEdgesAsLines ( )

Get a list of all the edges of the Polygon as Line2 objects.

Returns
A Line2 list of all edges.
void Otter.Polygon.OffsetPoints ( Vector2  vector)

Offset all the points by a Vector2 amount.

Parameters
vectorThe offset amount.
void Otter.Polygon.OffsetPoints ( float  x,
float  y 
)

Offset all the points by a Vector2 amount.

Parameters
vectorThe offset amount.
bool Otter.Polygon.Overlap ( Polygon  other)

Test another Polygon for an overlap. Will not work if either Polygon is concave!

Parameters
otherThe other polygon to check.
Returns
True if this polygon overlaps the other polygon.
Range Otter.Polygon.Projection ( Vector2  axis)

Project the polygon onto an axis.

Parameters
axisThe axis to project on.
Returns
The min and max values of the projection.
void Otter.Polygon.Rotate ( float  amount,
float  aroundX,
float  aroundY 
)

Rotate the polygon by a specified amount.

Parameters
amountThe amount in degrees to rotate.
aroundXThe X position to rotate around.
aroundYThe Y position to rotate around.
void Otter.Polygon.Scale ( float  amountX,
float  amountY,
float  aroundX,
float  aroundY 
)

Scale the polygon by a specified amount.

Parameters
amountXThe amount to scale horizontally.
amountYThe amount to scale veritcally.
aroundXThe X position to scale around.
aroundYThe Y position to scale around.
override string Otter.Polygon.ToString ( )

Convert to a string.

Returns
String of data about the Polygon.

Property Documentation

int Otter.Polygon.Count
get

The number of points in the Polygon.

float Otter.Polygon.HalfHeight
get

Half of the Height.

float Otter.Polygon.HalfWidth
get

Half of the Width.

float Otter.Polygon.Height
get

The Height of the polygon determined by the bottom most point minus the top most point.

List<Vector2> Otter.Polygon.Points
getset

The list of Vector2 points.

Vector2 Otter.Polygon.this[int index]
getset

The list of Vector2 points in the Polygon.

Parameters
indexThe index of the point.
Returns
The point at the specified index.
float Otter.Polygon.Width
get

The Width of the polygon determined by the right most point minus the left most point.


The documentation for this class was generated from the following file: