Generated by DocFX

Class Polygon

Represents an abstract polygon shape with three or more vectors

Inheritance
System.Object
Polygon
Hexagon
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 Source

Polygon(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 Source

Bounds

Bounding rectangle which contains the entirety of the polygon

Declaration
public Rectangle Bounds { get; }
Property Value
Type Description
Microsoft.Xna.Framework.Rectangle
| Improve this Doc View Source

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
| Improve this Doc View Source

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 Source

Contains(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
| Improve this Doc View Source

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.

Extension Methods

PolygonExtensions.ToRectangle(Polygon, Boolean)