Interface IPolygonOverlap<TShape>
Interface for computing when polygons overlap.
Namespace: Edgar.Legacy.GeneralAlgorithms.Algorithms.Polygons
Assembly: Edgar.dll
Syntax
public interface IPolygonOverlap<in TShape>
Type Parameters
Name | Description |
---|---|
TShape | This generic type lets us improve performance by using IntAlias. |
Methods
DoHaveMinimumDistance(TShape, Vector2Int, TShape, Vector2Int, Int32)
Checks if two polygons touch
Declaration
bool DoHaveMinimumDistance(TShape polygon1, Vector2Int position1, TShape polygon2, Vector2Int position2, int minimumDistance)
Parameters
Type | Name | Description |
---|---|---|
TShape | polygon1 | |
Vector2Int | position1 | |
TShape | polygon2 | |
Vector2Int | position2 | |
System.Int32 | minimumDistance |
Returns
Type | Description |
---|---|
System.Boolean |
DoOverlap(TShape, Vector2Int, TShape, Vector2Int)
Checks if two polygons overlap.
Declaration
bool DoOverlap(TShape polygon1, Vector2Int position1, TShape polygon2, Vector2Int position2)
Parameters
Type | Name | Description |
---|---|---|
TShape | polygon1 | |
Vector2Int | position1 | |
TShape | polygon2 | |
Vector2Int | position2 |
Returns
Type | Description |
---|---|
System.Boolean |
DoTouch(TShape, Vector2Int, TShape, Vector2Int, Int32)
Checks if two polygons touch
Declaration
bool DoTouch(TShape polygon1, Vector2Int position1, TShape polygon2, Vector2Int position2, int minimumLength = 0)
Parameters
Type | Name | Description |
---|---|---|
TShape | polygon1 | |
Vector2Int | position1 | |
TShape | polygon2 | |
Vector2Int | position2 | |
System.Int32 | minimumLength |
Returns
Type | Description |
---|---|
System.Boolean |
GetDistance(TShape, Vector2Int, TShape, Vector2Int)
Gets distance between the two polygons.
Declaration
int GetDistance(TShape polygon1, Vector2Int position1, TShape polygon2, Vector2Int position2)
Parameters
Type | Name | Description |
---|---|---|
TShape | polygon1 | |
Vector2Int | position1 | |
TShape | polygon2 | |
Vector2Int | position2 |
Returns
Type | Description |
---|---|
System.Int32 | -1 if polygons overlap 0 if polygons share at least one point positive number othetwise |
Remarks
We are interested in the smallest distance between any two points of given polygons. Manhattan distance is used.
OverlapAlongLine(TShape, TShape, OrthogonalLineGrid2D)
Returns a list of point where a given moving polygon starts or ends overlapping a given fixed polygon.
Declaration
IList<Tuple<Vector2Int, bool>> OverlapAlongLine(TShape movingPolygon, TShape fixedPolygon, OrthogonalLineGrid2D line)
Parameters
Type | Name | Description |
---|---|---|
TShape | movingPolygon | A polygon that will move along a given line. |
TShape | fixedPolygon | A polygon that stays fixed. |
OrthogonalLineGrid2D | line |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<System.Tuple<Vector2Int, System.Boolean>> |
Remarks
True - starts overlapping (inclusive) False - ends overlapping (inclusive)
The list must be normalized - containing the minimum number of points required. Default value of the list is false - empty list means no overlap.
OverlapArea(TShape, Vector2Int, TShape, Vector2Int)
Computes the area of overlap of two given polygons.
Declaration
int OverlapArea(TShape polygon1, Vector2Int position1, TShape polygon2, Vector2Int position2)
Parameters
Type | Name | Description |
---|---|---|
TShape | polygon1 | |
Vector2Int | position1 | |
TShape | polygon2 | |
Vector2Int | position2 |
Returns
Type | Description |
---|---|
System.Int32 |