Table of Contents

Class Polygon

Namespace
SimulationFramework
Assembly
SimulationFramework.dll

Contains various static methods for working with polygons.

public static class Polygon
Inheritance
Polygon
Inherited Members

Methods

Close(ReadOnlySpan<Vector2>)

Closes a polygon. This method returns a new polygon; polygon is unmodified.

public static Vector2[] Close(ReadOnlySpan<Vector2> polygon)

Parameters

polygon ReadOnlySpan<Vector2>

The polygon to close.

Returns

Vector2[]

The new closed polygon.

Close(ReadOnlySpan<Vector2>, Span<Vector2>)

Closes a polygon. The closed polygon is written to result; polygon is unmodified.

public static int Close(ReadOnlySpan<Vector2> polygon, Span<Vector2> result)

Parameters

polygon ReadOnlySpan<Vector2>
result Span<Vector2>

Returns

int

Exceptions

ArgumentException

CollideConvex(ReadOnlySpan<Vector2>, ReadOnlySpan<Vector2>)

Determines if two convex polygons are intersecting.

public static bool CollideConvex(ReadOnlySpan<Vector2> polygonA, ReadOnlySpan<Vector2> polygonB)

Parameters

polygonA ReadOnlySpan<Vector2>

The first polygon. This should be convex and non-self-intersecting.

polygonB ReadOnlySpan<Vector2>

The second polygon. This should be convex and non-self-intersecting.

Returns

bool

true if polygonA and polygonB are intersecting; otherwise false.

Remarks

This method does not check its arguments for non-convex or self-intersecting polygons. Passing invalid polygons will most likely give incorrect results.

CollideConvex(ReadOnlySpan<Vector2>, ReadOnlySpan<Vector2>, out Vector2)

Determines if two convex polygons are intersecting.

public static bool CollideConvex(ReadOnlySpan<Vector2> polygonA, ReadOnlySpan<Vector2> polygonB, out Vector2 minimumTranslationValue)

Parameters

polygonA ReadOnlySpan<Vector2>

The first polygon. This should be convex and non-self-intersecting.

polygonB ReadOnlySpan<Vector2>

The second polygon. This should be convex and non-self-intersecting.

minimumTranslationValue Vector2

If this method returns true, this is set to the smallest distance which one of the shapes could be moved to resolve the collison. Otherwise, this is Zero.

Returns

bool

true if polygonA and polygonB are intersecting; otherwise false.

Remarks

This method does not check its arguments for non-convex or self-intersecting polygons. Passing invalid polygons will most likely give incorrect results.

ContainsPoint(Span<Vector2>, Vector2)

Determines if a polygon contains a point.

public static bool ContainsPoint(Span<Vector2> polygon, Vector2 point)

Parameters

polygon Span<Vector2>

The polygon. May be convex or concave, but not self-intersecting.

point Vector2

The point.

Returns

bool

true when point is inside of polygon; otherwise false.

Exceptions

NotImplementedException

GetBoundingBox(ReadOnlySpan<Vector2>)

Finds the smallest possible rectangle that contains a polygon.

public static Rectangle GetBoundingBox(ReadOnlySpan<Vector2> polygon)

Parameters

polygon ReadOnlySpan<Vector2>

The polygon to find the bounds of.

Returns

Rectangle

The smallest possible rectangle that contains all the points in polygon.

IsClosed(ReadOnlySpan<Vector2>)

Determines if a polygon is closed.

public static bool IsClosed(ReadOnlySpan<Vector2> polygon)

Parameters

polygon ReadOnlySpan<Vector2>

Returns

bool

true if the polygon is closed; otherwise false.

IsConvex(ReadOnlySpan<Vector2>, out bool?)

Determines if a polygon is convex.

public static bool IsConvex(ReadOnlySpan<Vector2> polygon, out bool? isClockwise)

Parameters

polygon ReadOnlySpan<Vector2>

The polygon.

isClockwise bool?

Returns

bool

true if polygon is convex; otherwise false

IsSelfIntersecting(ReadOnlySpan<Vector2>)

Determines if a polygon is self-intersecting.

public static bool IsSelfIntersecting(ReadOnlySpan<Vector2> polygon)

Parameters

polygon ReadOnlySpan<Vector2>

The polygon to test for self-intersection.

Returns

bool

true if polygon is self-intersecting; otherwise false.