Class Polygon
Represents an abstract polygon shape with three or more vectors
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Ladybug
Assembly: ladybug.dll
Syntax
public class Polygon
Constructors
| Improve this Doc View SourcePolygon(Vector2[])
Creates a new polygon object from three or more vectors
Declaration
public Polygon(params Vector2[] vectors)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Vector2[] | vectors |
Properties
| Improve this Doc View SourceBounds
Bounding rectangle which contains the entirety of the polygon
Declaration
public Rectangle Bounds { get; }
Property Value
Type | Description |
---|---|
Microsoft.Xna.Framework.Rectangle |
Centroid
The mathematical center of the polygon, constructed from the average position of all of its points
Declaration
public Vector2 Centroid { get; }
Property Value
Type | Description |
---|---|
Microsoft.Xna.Framework.Vector2 |
Points
The vertices of the polygon
Declaration
public Vector2[] Points { get; protected set; }
Property Value
Type | Description |
---|---|
Microsoft.Xna.Framework.Vector2[] |
Methods
| Improve this Doc View SourceContains(Vector2)
Returns true
if the given vector lies within the bounds of the polygon
Declaration
public virtual bool Contains(Vector2 vector)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Vector2 | vector |
Returns
Type | Description |
---|---|
System.Boolean |
SortPoints()
Sorts the Polygon's vertices clockwise around its centroid.
Declaration
public void SortPoints()
Remarks
As this uses the centroid of the polygon, the more irregular the polygon, the less likely sorting it will result in an accurate shape. It is advised to construct highly-irregular polygons from an already-sorted list of points rather than sorting them afterward.