 Otter  0.9.88 2d Game Development Framework based on SFML.Net
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...

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...

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
 points The Vector2 points composing the Polygon.
 Otter.Polygon.Polygon ( Polygon copy )

Create a new Polygon.

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

Create a new Polygon.

Parameters
 points A 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
 point The Vector2 to add the points.
 void Otter.Polygon.Add ( float x, float y )

Add an X Y position to the list of points.

Parameters
 x The X position to add. y The 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
 point The 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
 x The X position of the point to check for. y The 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
 radius The radius of the circle. steps How 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
 width The width of the rectangle. height The height of the rectangle.
Returns
A rectangle shaped Polygon.
 List Otter.Polygon.GetAxes ( )

Get the axes to project on.

Returns
A list of normals from the polygon.
 List 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
 vector The offset amount.
 void Otter.Polygon.OffsetPoints ( float x, float y )

Offset all the points by a Vector2 amount.

Parameters
 vector The offset amount.
 bool Otter.Polygon.Overlap ( Polygon other )

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

Parameters
 other The 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
 axis The 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
 amount The amount in degrees to rotate. aroundX The X position to rotate around. aroundY The 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
 amountX The amount to scale horizontally. amountY The amount to scale veritcally. aroundX The X position to scale around. aroundY The 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 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
 index The 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:
• Otter/Utility/Polygon.cs