Class PolygonGrid2D
A class representing an immutable polygon where each of its vertices has integer coordinates.
Inheritance
System.Object
PolygonGrid2D
Assembly: Edgar.dll
Syntax
public class PolygonGrid2D : Object
Constructors
PolygonGrid2D(IEnumerable<Vector2Int>)
Create a polygon with given points.
Declaration
public PolygonGrid2D(IEnumerable<Vector2Int> points)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<Vector2Int> |
points |
|
Exceptions
Type |
Condition |
System.ArgumentException |
Thrown when invariants do not hold
|
Fields
PossibleRotations
Declaration
public static readonly int[] PossibleRotations
Field Value
Type |
Description |
System.Int32[] |
|
Properties
BoundingRectangle
Declaration
public RectangleGrid2D BoundingRectangle { get; }
Property Value
Methods
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
GetAllRotations()
Get all possible rotations of the polygon.
Declaration
public IEnumerable<PolygonGrid2D> GetAllRotations()
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<PolygonGrid2D> |
|
Get all possible transformations of the polygon.
Declaration
public IEnumerable<PolygonGrid2D> GetAllTransformations()
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<PolygonGrid2D> |
|
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
GetLines()
Gets all lines of the polygon ordered as they appear on the polygon.
Declaration
public List<OrthogonalLineGrid2D> GetLines()
Returns
GetPoints()
Gets point of the polygon.
Declaration
public ReadOnlyCollection<Vector2Int> GetPoints()
Returns
Type |
Description |
System.Collections.ObjectModel.ReadOnlyCollection<Vector2Int> |
|
GetRectangle(Int32, Int32)
Helper method to create a rectangle with given sides.
Declaration
public static PolygonGrid2D GetRectangle(int width, int height)
Parameters
Type |
Name |
Description |
System.Int32 |
width |
|
System.Int32 |
height |
|
Returns
GetSquare(Int32)
Helper method for creating a polygon with side a.
Declaration
public static PolygonGrid2D GetSquare(int a)
Parameters
Type |
Name |
Description |
System.Int32 |
a |
Length of the side.
|
Returns
Rotate(Int32)
Declaration
public PolygonGrid2D Rotate(int degrees)
Parameters
Type |
Name |
Description |
System.Int32 |
degrees |
Degrees divisble by 90.
|
Returns
Scale(Vector2Int)
Declaration
public PolygonGrid2D Scale(Vector2Int factor)
Parameters
Returns
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Transforms a given polygon.
Declaration
public PolygonGrid2D Transform(TransformationGrid2D transformation)
Parameters
Returns
Operators
Addition(PolygonGrid2D, Vector2Int)
Computes a polygon that has all points moved by a given position.
Declaration
public static PolygonGrid2D operator +(PolygonGrid2D polygon, Vector2Int position)
Parameters
Returns