Array of points defining the Polygon
Note: If you manually change points
, you must call recalc
afterwards so that the changes get applied correctly.
origin point of the Polygon
the shape type (used internally)
Returns true if the polygon contains the given 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)
Rest
...args: any[]True if the polygon contain the point, otherwise false
Rotate this Polygon (counter-clockwise) by the specified angle (in radians).
The angle to rotate (in radians)
Optional
v: Vector2d | ObservableVector2dan optional point to rotate around
Reference to this object for method chaining
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 if its vertices (points) are declared turning to the right. The image above shows COUNTERCLOCKWISE winding.