Polygon
Namespace: Murder.Core.Geometry
Assembly: Murder.dll
public sealed struct Polygon
⭐ Constructors
public Polygon()
public Polygon(IEnumerable<T> vertices, Vector2 position)
Parameters
vertices
IEnumerable<T>
position
Vector2
public Polygon(IEnumerable<T> vertices)
Parameters
vertices
IEnumerable<T>
⭐ Properties
DIAMOND
public readonly static Polygon DIAMOND;
Returns
Polygon
EMPTY
public readonly static Polygon EMPTY;
Returns
Polygon
Vertices
public readonly ImmutableArray<T> Vertices;
Returns
ImmutableArray<T>
⭐ Methods
Contains(Point)
public bool Contains(Point point)
Parameters
point
Point
Returns
bool
Contains(Vector2)
public bool Contains(Vector2 vector)
Parameters
vector
Vector2
Returns
bool
IsClockwise(List)
public bool IsClockwise(List<T> vertices)
Parameters
vertices
List<T>
Returns
bool
IsConvex()
public bool IsConvex()
Returns
bool
IsPointInTriangle(Vector2, Vector2, Vector2, Vector2)
public bool IsPointInTriangle(Vector2 point, Vector2 a, Vector2 b, Vector2 c)
Parameters
point
Vector2
a
Vector2
b
Vector2
c
Vector2
Returns
bool
TryMerge(Polygon, Polygon, float, out Polygon&)
public bool TryMerge(Polygon a, Polygon b, float minDistance, Polygon& result)
Parameters
a
Polygon
b
Polygon
minDistance
float
result
Polygon&
Returns
bool
GetNormals()
public IEnumerable<T> GetNormals()
Returns
IEnumerable<T>
GetLines()
public Line2[] GetLines()
Returns
Line2[]
EarClippingTriangulation(Polygon)
public List<T> EarClippingTriangulation(Polygon polygon)
Parameters
polygon
Polygon
Returns
List<T>
FindConcaveVertices(ImmutableArray)
public List<T> FindConcaveVertices(ImmutableArray<T> points)
Parameters
points
ImmutableArray<T>
Returns
List<T>
PartitionToConvex(Polygon)
public List<T> PartitionToConvex(Polygon concave)
This doesn't work yet
Parameters
concave
Polygon
Returns
List<T>
ReorderVertices(List)
public List<T> ReorderVertices(List<T> vertices)
Parameters
vertices
List<T>
Returns
List<T>
AddPosition(Vector2)
public Polygon AddPosition(Vector2 add)
Parameters
add
Vector2
Returns
Polygon
AtPosition(Point)
public Polygon AtPosition(Point target)
Returns this polygon with a new position. The position is calculated using the vertice 0 as origin.
Parameters
target
Point
Returns
Polygon
Exceptions
NotImplementedException
FromRectangle(int, int, int, int)
public Polygon FromRectangle(int x, int y, int width, int height)
Parameters
x
int
y
int
width
int
height
int
Returns
Polygon
RemoveVerticeAt(int)
public Polygon RemoveVerticeAt(int index)
Parameters
index
int
Returns
Polygon
WithNewVerticeAt(int, Vector2)
public Polygon WithNewVerticeAt(int index, Vector2 target)
Parameters
index
int
target
Vector2
Returns
Polygon
WithVerticeAt(int, Vector2)
public Polygon WithVerticeAt(int index, Vector2 target)
Parameters
index
int
target
Vector2
Returns
Polygon
GetBoundingBox()
public Rectangle GetBoundingBox()
Returns
Rectangle
Intersects(Polygon, Vector2, Vector2)
public T? Intersects(Polygon other, Vector2 positionA, Vector2 positionB)
Check if a polygon is inside another, if they do, return the minimum translation vector to move the polygon out of the other.
Parameters
other
Polygon
positionA
Vector2
positionB
Vector2
Returns
T?
MergePolygons(Polygon, Polygon)
public T? MergePolygons(Polygon a, Polygon b)
Parameters
a
Polygon
b
Polygon
Returns
T?
ProjectOntoAxis(Vector2, Vector2)
public ValueTuple<T1, T2> ProjectOntoAxis(Vector2 axis, Vector2 offset)
Parameters
axis
Vector2
offset
Vector2
Returns
ValueTuple<T1, T2>
Draw(Batch2D, Vector2, bool, Color)
public void Draw(Batch2D batch, Vector2 position, bool flip, Color color)
Parameters
batch
Batch2D
position
Vector2
flip
bool
color
Color
⚡