Show / Hide Table of Contents

Class PolygonOverlapBase<TShape>

Base class for implementing the IPolygonOverlap<TShape> interface.

Inheritance
System.Object
PolygonOverlapBase<TShape>
FastPolygonOverlap
PolygonOverlap
Implements
IPolygonOverlap<TShape>
Namespace: Edgar.Legacy.GeneralAlgorithms.Algorithms.Polygons
Assembly: Edgar.dll
Syntax
public abstract class PolygonOverlapBase<TShape> : Object, IPolygonOverlap<TShape>
Type Parameters
Name Description
TShape

Constructors

PolygonOverlapBase()

Declaration
protected PolygonOverlapBase()

Methods

DoHaveMinimumDistance(TShape, Vector2Int, TShape, Vector2Int, Int32)

Declaration
public 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

DoHaveMinimumDistance(RectangleGrid2D, RectangleGrid2D, Int32)

Declaration
protected bool DoHaveMinimumDistance(RectangleGrid2D rectangle1, RectangleGrid2D rectangle2, int minimumDistance)
Parameters
Type Name Description
RectangleGrid2D rectangle1
RectangleGrid2D rectangle2
System.Int32 minimumDistance
Returns
Type Description
System.Boolean

DoOverlap(TShape, Vector2Int, TShape, Vector2Int)

Checks if two polygons overlap.

Declaration
public 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

DoOverlap(RectangleGrid2D, RectangleGrid2D)

Checks if two rectangles overlap.

Declaration
public bool DoOverlap(RectangleGrid2D rectangle1, RectangleGrid2D rectangle2)
Parameters
Type Name Description
RectangleGrid2D rectangle1
RectangleGrid2D rectangle2
Returns
Type Description
System.Boolean

DoOverlap(RectangleGrid2D, Vector2Int, RectangleGrid2D, Vector2Int)

Declaration
public bool DoOverlap(RectangleGrid2D rectangle1, Vector2Int position1, RectangleGrid2D rectangle2, Vector2Int position2)
Parameters
Type Name Description
RectangleGrid2D rectangle1
Vector2Int position1
RectangleGrid2D rectangle2
Vector2Int position2
Returns
Type Description
System.Boolean

DoTouch(TShape, Vector2Int, TShape, Vector2Int, Int32)

Checks if two polygons touch

Declaration
public 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

DoTouch(RectangleGrid2D, RectangleGrid2D, Int32)

Declaration
protected bool DoTouch(RectangleGrid2D rectangle1, RectangleGrid2D rectangle2, int minimumLength)
Parameters
Type Name Description
RectangleGrid2D rectangle1
RectangleGrid2D rectangle2
System.Int32 minimumLength
Returns
Type Description
System.Boolean

GetBoundingRectangle(TShape)

Gets the bounding rectangle for a given polygon.

Declaration
protected abstract RectangleGrid2D GetBoundingRectangle(TShape polygon)
Parameters
Type Name Description
TShape polygon
Returns
Type Description
RectangleGrid2D

GetDecomposition(TShape)

Gets a decomposition of a given polygon.

Declaration
protected abstract List<RectangleGrid2D> GetDecomposition(TShape polygon)
Parameters
Type Name Description
TShape polygon
Returns
Type Description
System.Collections.Generic.List<RectangleGrid2D>

GetDistance(TShape, Vector2Int, TShape, Vector2Int)

Gets distance between the two polygons.

Declaration
public 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.

MergeEvents(List<Tuple<Vector2Int, Boolean>>, List<Tuple<Vector2Int, Boolean>>, OrthogonalLineGrid2D)

Merges two lists of events.

Declaration
protected List<Tuple<Vector2Int, bool>> MergeEvents(List<Tuple<Vector2Int, bool>> events1, List<Tuple<Vector2Int, bool>> events2, OrthogonalLineGrid2D line)
Parameters
Type Name Description
System.Collections.Generic.List<System.Tuple<Vector2Int, System.Boolean>> events1
System.Collections.Generic.List<System.Tuple<Vector2Int, System.Boolean>> events2
OrthogonalLineGrid2D line
Returns
Type Description
System.Collections.Generic.List<System.Tuple<Vector2Int, System.Boolean>>

OverlapAlongLine(TShape, TShape, OrthogonalLineGrid2D)

Returns a list of point where a given moving polygon starts or ends overlapping a given fixed polygon.

Declaration
public 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.

OverlapAlongLine(RectangleGrid2D, RectangleGrid2D, OrthogonalLineGrid2D, Int32)

Computes the overlap along a line of a given moving rectangle and a fixed rectangle.

Declaration
protected List<Tuple<Vector2Int, bool>> OverlapAlongLine(RectangleGrid2D movingRectangle, RectangleGrid2D fixedRectangle, OrthogonalLineGrid2D line, int movingRectangleOffset = 0)
Parameters
Type Name Description
RectangleGrid2D movingRectangle
RectangleGrid2D fixedRectangle
OrthogonalLineGrid2D line
System.Int32 movingRectangleOffset
Returns
Type Description
System.Collections.Generic.List<System.Tuple<Vector2Int, System.Boolean>>

OverlapAlongLine(RectangleGrid2D, IList<RectangleGrid2D>, OrthogonalLineGrid2D, Int32)

Computes the overlap along a line of a given moving rectangle and a set o fixed rectangles.

Declaration
protected List<Tuple<Vector2Int, bool>> OverlapAlongLine(RectangleGrid2D movingRectangle, IList<RectangleGrid2D> fixedRectangles, OrthogonalLineGrid2D line, int movingRectangleOffset = 0)
Parameters
Type Name Description
RectangleGrid2D movingRectangle
System.Collections.Generic.IList<RectangleGrid2D> fixedRectangles
OrthogonalLineGrid2D line
System.Int32 movingRectangleOffset

Specifies the X-axis offset of a given moving rectangle.

Returns
Type Description
System.Collections.Generic.List<System.Tuple<Vector2Int, System.Boolean>>

OverlapArea(TShape, Vector2Int, TShape, Vector2Int)

Computes the area of overlap of two given polygons.

Declaration
public 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

ReverseEvents(List<Tuple<Vector2Int, Boolean>>, OrthogonalLineGrid2D)

Reverses a given events list in a way that the line has the opposite direction.

Declaration
protected List<Tuple<Vector2Int, bool>> ReverseEvents(List<Tuple<Vector2Int, bool>> events, OrthogonalLineGrid2D line)
Parameters
Type Name Description
System.Collections.Generic.List<System.Tuple<Vector2Int, System.Boolean>> events
OrthogonalLineGrid2D line
Returns
Type Description
System.Collections.Generic.List<System.Tuple<Vector2Int, System.Boolean>>

Implements

IPolygonOverlap<TShape>
Back to top Generated by DocFX