## me.Polygon(x, y, points)

#### new Polygon(x, y, points)

a polygon Object.
Please do note that melonJS implements a simple Axis-Aligned Boxes collision algorithm, which requires all polygons used for collision to be convex with all vertices defined with clockwise winding. A polygon is convex when all line segments connecting two points in the interior do not cross any edge of the polygon (which means that all angles are less than 180 degrees), as described here below : A polygon's `winding` is clockwise iff its vertices (points) are declared turning to the right. The image above shows COUNTERCLOCKWISE winding.

##### Parameters:
Name Type Description
`x` Number

origin point of the Polygon

`y` Number

origin point of the Polygon

`points` Array.<me.Vector2d>

array of vector defining the Polygon

### Members

#### static points :Array.<me.Vector2d>

Array of points defining the Polygon
Note: If you manually change `points`, you must call `recalc`afterwards so that the changes get applied correctly.

#### static pos :me.Vector2d

origin point of the Polygon

### Methods

#### static clone() → {me.Polygon}

clone this Polygon

me.Polygon -

new Polygon

#### static containsPoint(x, y) → {boolean}

check if this Polygon contains the specified point
(Note: it is highly recommended to first do a hit test on the corresponding
bounding rect, as the function can be highly consuming with complex shapes)

##### Parameters:
Name Type Description
`x` Number

x coordinate

`y` Number

y coordinate

boolean -

true if contains

#### static containsPointV(point) → {boolean}

check if this Polygon contains the specified point

##### Parameters:
Name Type Description
`point` me.Vector2d
boolean -

true if contains

#### static getBounds() → {me.Rect}

returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.

##### Returns:
me.Rect -

this shape bounding box Rectangle object

#### static getIndices(a) → {me.Polygon}

returns a list of indices for all triangles defined in this polygon

##### Parameters:
Name Type Description
`a` Array.<Vector2d>

list of vector

me.Polygon -

this Polygon

#### static recalc() → {me.Polygon}

Computes the calculated collision polygon. This must be called if the `points` array, `angle`, or `offset` is modified manually.

##### Returns:
me.Polygon -

Reference to this object for method chaining

#### static rotate(angle) → {me.Polygon}

Rotate this Polygon (counter-clockwise) by the specified angle (in radians).

##### Parameters:
Name Type Description
`angle` Number

The angle to rotate (in radians)

##### Returns:
me.Polygon -

Reference to this object for method chaining

#### static scale(x, yopt) → {me.Polygon}

Scale this Polygon by the given scalar.

##### Parameters:
Name Type Attributes Default Description
`x` Number
`y` Number <optional>
x
##### Returns:
me.Polygon -

Reference to this object for method chaining

#### static scaleV(v) → {me.Polygon}

Scale this Polygon by the given vector

##### Parameters:
Name Type Description
`v` me.Vector2d
##### Returns:
me.Polygon -

Reference to this object for method chaining

#### static setShape(x, y, points)

set new value to the Polygon

##### Parameters:
Name Type Description
`x` Number

position of the Polygon

`y` Number

position of the Polygon

`points` Array.<me.Vector2d>

array of vector defining the Polygon

#### static to2d() → {me.Polygon}

apply a 2d projection to this shape

##### Returns:
me.Polygon -

Reference to this object for method chaining

#### static toIso() → {me.Polygon}

apply an isometric projection to this shape

##### Returns:
me.Polygon -

Reference to this object for method chaining

#### static transform(matrix) → {me.Polygon}

apply the given transformation matrix to this Polygon

##### Parameters:
Name Type Description
`matrix` me.Matrix2d

the transformation matrix

##### Returns:
me.Polygon -

Reference to this object for method chaining

#### static translate(x, y) → {me.Polygon}

translate the Polygon by the specified offset

##### Parameters:
Name Type Description
`x` Number

x offset

`y` Number

y offset

me.Polygon -

this Polygon

#### static translateV(v) → {me.Polygon}

translate the Polygon by the specified vector

##### Parameters:
Name Type Description
`v` me.Vector2d

vector offset

##### Returns:
me.Polygon -

Reference to this object for method chaining

#### static updateBounds() → {me.Rect}

update the bounding box for this shape.

##### Returns:
me.Rect -

this shape bounding box Rectangle object