Geometry2D
Analytic 2D geometry, contour operations and rectangle packing.
Static CPU operations on supplied points. They neither query the physics world nor use collision layers or automatically create CollisionPolygon2D objects/textures. Keep every input in one coordinate system. Singleton is borrowed: do not Free/Dispose it.
LineIntersectsLine takes a point and direction for each infinite line; SegmentIntersectsSegment takes endpoints of two finite segments. The Variant result contains Vector2 or Nil; collinear overlap produces no single-point result. SegmentIntersectsCircle instead returns a fraction t in 0…1 or -1 on miss. Unlike the corresponding 3D method, the 2D function includes exact tangency and can return an exit from an inside start.
float t = Geometry2D.SegmentIntersectsCircle(
new Vector2(-2, 0), new Vector2(2, 0), Vector2.Zero, 1);
if (t >= 0)
{
Vector2 hit = new Vector2(-2, 0).Lerp(new Vector2(2, 0), t);
}Boolean operations return an Array<Vector2[]> of contours: Merge is union, Clip is A minus B, Intersect is shared area, and Exclude is XOR. A result can contain multiple outer boundaries and holes. Do not fill every contour as an independent solid polygon because that fills holes. Contour order/start vertex are not stable IDs. Operations use EvenOdd fill and internal precision of 5 decimal places rather than exact arbitrary-scale arithmetic.
IsPolygonClockwise uses Cartesian Y-up coordinates; apparent winding on a Y-down screen is reversed. IsPointInPolygon accepts boundary points with tolerance, but PointIsInsideTriangle has no universal equivalent contract: reversing winding changes an edge case. Do not use it to validate degenerate triangles.
OffsetPolygon expands/contracts a closed region. OffsetPolyline creates a stroke approximately 2*abs(delta) wide: current Clipper2 takes the absolute delta for open paths. Negative delta neither contracts a line nor guarantees an empty result. Array overloads provide default join/end values, while span overloads require explicit enums.
ConvexHull repeats its first vertex at the end; remove that closing duplicate and validate a simple contour before TriangulatePolygon. TriangulatePolygon uses one polygon boundary; TriangulateDelaunay uses a point cloud without preserving concave boundaries/holes. MakeAtlas returns rectangle placements rather than an image; validate sizes before calling, particularly excluding widths above 4096 for the current algorithm.
38 Windows headless checks covered simple intersections, boundaries, boolean areas/a hole, strokes, triangulation and a small atlas. Arbitrary topology, extreme-scale accuracy, large atlases, physics-world behavior, performance and rendering were not tested.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties1
SingletonProperty
public static Geometry2DInstance Singleton { get; }Borrowed Geometry2DInstance behind static operations. Do not dispose it manually or create another service instance.
Methods39
BresenhamLineReckfell.Collections.Array<Vector2I>
public static Reckfell.Collections.Array<Vector2I> BresenhamLine(Vector2I from, Vector2I to);Returns integer Bresenham cells including both endpoints. Equal endpoints produce one point. Neither supercover of every touched cell nor a physics raycast; result length grows with distance.
| Name | Type | Default |
|---|---|---|
from | Vector2I | — |
to | Vector2I | — |
fromInteger Bresenham endpoint; both ends are included.
toInteger Bresenham endpoint; both ends are included.
Reckfell.Collections.Array<Vector2I>Array<Vector2I> of ordered cells from from to to inclusive.
ClipPolygons2 overloads
public static Reckfell.Collections.Array<Vector2[]> ClipPolygons(Vector2[] polygonA, Vector2[] polygonB);Difference A−B, removing B from A. Neither XOR nor intersection. Nested B can produce a separate hole contour that must not be filled independently as solid.
| Name | Type | Default |
|---|---|---|
polygonA | Vector2[] | — |
polygonB | Vector2[] | — |
polygonAOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
polygonBOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
public static Reckfell.Collections.Array<Vector2[]> ClipPolygons(ReadOnlySpan<Vector2> polygonA, ReadOnlySpan<Vector2> polygonB);Difference A−B, removing B from A. Neither XOR nor intersection. Nested B can produce a separate hole contour that must not be filled independently as solid.
| Name | Type | Default |
|---|---|---|
polygonA | ReadOnlySpan<Vector2> | — |
polygonB | ReadOnlySpan<Vector2> | — |
polygonAOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
polygonBOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
ClipPolylineWithPolygon2 overloads
public static Reckfell.Collections.Array<Vector2[]> ClipPolylineWithPolygon(Vector2[] polyline, Vector2[] polygon);Retains open-polyline portions outside polygon. A line can split into multiple open fragments rather than filled polygons.
| Name | Type | Default |
|---|---|---|
polyline | Vector2[] | — |
polygon | Vector2[] | — |
polylineOrdered open-line vertices, normally at least two distinct points.
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> of open fragments, possibly empty.
public static Reckfell.Collections.Array<Vector2[]> ClipPolylineWithPolygon(ReadOnlySpan<Vector2> polyline, ReadOnlySpan<Vector2> polygon);Retains open-polyline portions outside polygon. A line can split into multiple open fragments rather than filled polygons.
| Name | Type | Default |
|---|---|---|
polyline | ReadOnlySpan<Vector2> | — |
polygon | ReadOnlySpan<Vector2> | — |
polylineOrdered open-line vertices, normally at least two distinct points.
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> of open fragments, possibly empty.
ConvexHull2 overloads
public static Vector2[] ConvexHull(Vector2[] points);Builds a point-cloud convex hull by sorting an input copy. A normal nondegenerate hull is counterclockwise in Y-up coordinates and repeats the first vertex at the end. Interior/redundant collinear points need not be retained.
| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
pointsFinite Vector2 cloud in common coordinates; Delaunay needs nondegenerate noncollinear data.
Vector2[]Vector2[] hull with a closing duplicate for ordinary nondegenerate input.
public static Vector2[] ConvexHull(ReadOnlySpan<Vector2> points);Builds a point-cloud convex hull by sorting an input copy. A normal nondegenerate hull is counterclockwise in Y-up coordinates and repeats the first vertex at the end. Interior/redundant collinear points need not be retained.
| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
pointsFinite Vector2 cloud in common coordinates; Delaunay needs nondegenerate noncollinear data.
Vector2[]Vector2[] hull with a closing duplicate for ordinary nondegenerate input.
DecomposePolygonInConvex2 overloads
public static Reckfell.Collections.Array<Vector2[]> DecomposePolygonInConvex(Vector2[] polygon);Decomposes a simple concave polygon into convex contours, not necessarily triangles. Input is one valid contour; independently filling/decomposing every ring of a boolean result does not preserve holes.
| Name | Type | Default |
|---|---|---|
polygon | Vector2[] | — |
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> of convex parts of one polygon; failure can yield empty. This input does not specify separate hole rings.
public static Reckfell.Collections.Array<Vector2[]> DecomposePolygonInConvex(ReadOnlySpan<Vector2> polygon);Decomposes a simple concave polygon into convex contours, not necessarily triangles. Input is one valid contour; independently filling/decomposing every ring of a boolean result does not preserve holes.
| Name | Type | Default |
|---|---|---|
polygon | ReadOnlySpan<Vector2> | — |
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> of convex parts of one polygon; failure can yield empty. This input does not specify separate hole rings.
ExcludePolygons2 overloads
public static Reckfell.Collections.Array<Vector2[]> ExcludePolygons(Vector2[] polygonA, Vector2[] polygonB);Symmetric difference XOR retaining area filled by exactly one polygon. Unlike ClipPolygons, also includes B outside A.
| Name | Type | Default |
|---|---|---|
polygonA | Vector2[] | — |
polygonB | Vector2[] | — |
polygonAOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
polygonBOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
public static Reckfell.Collections.Array<Vector2[]> ExcludePolygons(ReadOnlySpan<Vector2> polygonA, ReadOnlySpan<Vector2> polygonB);Symmetric difference XOR retaining area filled by exactly one polygon. Unlike ClipPolygons, also includes B outside A.
| Name | Type | Default |
|---|---|---|
polygonA | ReadOnlySpan<Vector2> | — |
polygonB | ReadOnlySpan<Vector2> | — |
polygonAOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
polygonBOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
GetClosestPointToSegmentVector2
public static Vector2 GetClosestPointToSegment(Vector2 point, Vector2 s1, Vector2 s2);Projects point onto finite s1–s2 and clamps to endpoints. Near-zero segments return s1. Compute distance separately.
| Name | Type | Default |
|---|---|---|
point | Vector2 | — |
s1 | Vector2 | — |
s2 | Vector2 | — |
pointQuery point in the same coordinates as the geometry.
s1Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
s2Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
Vector2Projected Vector2 rather than distance.
GetClosestPointToSegmentUncappedVector2
public static Vector2 GetClosestPointToSegmentUncapped(Vector2 point, Vector2 s1, Vector2 s2);Projects onto the infinite line through s1/s2 without endpoint clamping. Near-coincident endpoints return s1.
| Name | Type | Default |
|---|---|---|
point | Vector2 | — |
s1 | Vector2 | — |
s2 | Vector2 | — |
pointQuery point in the same coordinates as the geometry.
s1Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
s2Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
Vector2Projected Vector2 rather than distance.
GetClosestPointsBetweenSegmentsVector2[]
public static Vector2[] GetClosestPointsBetweenSegments(Vector2 p1, Vector2 q1, Vector2 p2, Vector2 q2);Returns two closest points: first on p1–q1, second on p2–q2. Parameter naming differs from Geometry3D. Neither a pair of intersections nor distance.
| Name | Type | Default |
|---|---|---|
p1 | Vector2 | — |
q1 | Vector2 | — |
p2 | Vector2 | — |
q2 | Vector2 | — |
p1Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
q1Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
p2Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
q2Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
Vector2[]Two Vector2 values: point on p1–q1, then p2–q2.
IntersectPolygons2 overloads
public static Reckfell.Collections.Array<Vector2[]> IntersectPolygons(Vector2[] polygonA, Vector2[] polygonB);Intersection A∩B retaining shared filled area only. Without shared area the result can be empty; not a single touching-point query.
| Name | Type | Default |
|---|---|---|
polygonA | Vector2[] | — |
polygonB | Vector2[] | — |
polygonAOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
polygonBOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
public static Reckfell.Collections.Array<Vector2[]> IntersectPolygons(ReadOnlySpan<Vector2> polygonA, ReadOnlySpan<Vector2> polygonB);Intersection A∩B retaining shared filled area only. Without shared area the result can be empty; not a single touching-point query.
| Name | Type | Default |
|---|---|---|
polygonA | ReadOnlySpan<Vector2> | — |
polygonB | ReadOnlySpan<Vector2> | — |
polygonAOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
polygonBOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
IntersectPolylineWithPolygon2 overloads
public static Reckfell.Collections.Array<Vector2[]> IntersectPolylineWithPolygon(Vector2[] polyline, Vector2[] polygon);Retains open-polyline portions inside polygon. Returns open fragments rather than filled area or automatically closed contours.
| Name | Type | Default |
|---|---|---|
polyline | Vector2[] | — |
polygon | Vector2[] | — |
polylineOrdered open-line vertices, normally at least two distinct points.
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> of open fragments, possibly empty.
public static Reckfell.Collections.Array<Vector2[]> IntersectPolylineWithPolygon(ReadOnlySpan<Vector2> polyline, ReadOnlySpan<Vector2> polygon);Retains open-polyline portions inside polygon. Returns open fragments rather than filled area or automatically closed contours.
| Name | Type | Default |
|---|---|---|
polyline | ReadOnlySpan<Vector2> | — |
polygon | ReadOnlySpan<Vector2> | — |
polylineOrdered open-line vertices, normally at least two distinct points.
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> of open fragments, possibly empty.
IsPointInCirclebool
public static bool IsPointInCircle(Vector2 point, Vector2 circlePosition, float circleRadius);Checks squared distance ≤ radius², including the boundary. Use nonnegative radius: the formula squares it without validating negative-value semantics.
| Name | Type | Default |
|---|---|---|
point | Vector2 | — |
circlePosition | Vector2 | — |
circleRadius | float | — |
pointQuery point in the same coordinates as the geometry.
circlePositionCircle center in common coordinates.
circleRadiusNonnegative finite radius in point units.
boolBoolean result subject to the boundary rules in the method description.
IsPointInPolygon2 overloads
public static bool IsPointInPolygon(Vector2 point, Vector2[] polygon);Tests a point in one contour using ray crossing; an edge hit is included with approximate comparison. Fewer than three vertices give false. Multiple contours/holes must not be passed as one unordered array.
| Name | Type | Default |
|---|---|---|
point | Vector2 | — |
polygon | Vector2[] | — |
pointQuery point in the same coordinates as the geometry.
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
boolBoolean result subject to the boundary rules in the method description.
public static bool IsPointInPolygon(Vector2 point, ReadOnlySpan<Vector2> polygon);Tests a point in one contour using ray crossing; an edge hit is included with approximate comparison. Fewer than three vertices give false. Multiple contours/holes must not be passed as one unordered array.
| Name | Type | Default |
|---|---|---|
point | Vector2 | — |
polygon | ReadOnlySpan<Vector2> | — |
pointQuery point in the same coordinates as the geometry.
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
boolBoolean result subject to the boundary rules in the method description.
IsPolygonClockwise2 overloads
public static bool IsPolygonClockwise(Vector2[] polygon);Tests closed-contour winding in Cartesian Y-up coordinates. Apparent winding reverses on Y-down screens. Fewer than three points return false, which does not establish valid opposite winding.
| Name | Type | Default |
|---|---|---|
polygon | Vector2[] | — |
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
boolBoolean result subject to the boundary rules in the method description.
public static bool IsPolygonClockwise(ReadOnlySpan<Vector2> polygon);Tests closed-contour winding in Cartesian Y-up coordinates. Apparent winding reverses on Y-down screens. Fewer than three points return false, which does not establish valid opposite winding.
| Name | Type | Default |
|---|---|---|
polygon | ReadOnlySpan<Vector2> | — |
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
boolBoolean result subject to the boundary rules in the method description.
LineIntersectsLineVariant
public static Variant LineIntersectsLine(Vector2 fromA, Vector2 dirA, Vector2 fromB, Vector2 dirB);Intersects infinite lines from+dir*t for either sign of t. dir is a direction rather than a second endpoint. Parallel/coincident lines give Nil rather than a set of points.
| Name | Type | Default |
|---|---|---|
fromA | Vector2 | — |
dirA | Vector2 | — |
fromB | Vector2 | — |
dirB | Vector2 | — |
fromAPoint in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
dirANonzero infinite-line direction rather than a second endpoint.
fromBPoint in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
dirBNonzero infinite-line direction rather than a second endpoint.
VariantVariant containing Vector2 or Nil; dispose after use and do not treat (0,0) as a miss sentinel.
MakeAtlas2 overloads
public static Reckfell.Collections.Dictionary MakeAtlas(Vector2[] sizes);Computes rectangle positions without rotation, padding or texture creation. Vector2 sizes convert to integers by truncation; supply a nonempty set of positive integer sizes. Current search considers widths only up to 4096: do not pass wider rectangles; safe output is unestablished and code does not guard an empty candidate list before selection. This is a source observation; crash-prone input was not executed.
| Name | Type | Default |
|---|---|---|
sizes | Vector2[] | — |
sizesNonempty positive integer sizes, each width ≤4096; fractions truncate and can become zero.
Reckfell.Collections.DictionaryOwned Dictionary: points is a Vector2[] of placements in original-index order; size is total Vector2I dimensions. Dispose the dictionary after reading.
public static Reckfell.Collections.Dictionary MakeAtlas(ReadOnlySpan<Vector2> sizes);Computes rectangle positions without rotation, padding or texture creation. Vector2 sizes convert to integers by truncation; supply a nonempty set of positive integer sizes. Current search considers widths only up to 4096: do not pass wider rectangles; safe output is unestablished and code does not guard an empty candidate list before selection. This is a source observation; crash-prone input was not executed.
| Name | Type | Default |
|---|---|---|
sizes | ReadOnlySpan<Vector2> | — |
sizesNonempty positive integer sizes, each width ≤4096; fractions truncate and can become zero.
Reckfell.Collections.DictionaryOwned Dictionary: points is a Vector2[] of placements in original-index order; size is total Vector2I dimensions. Dispose the dictionary after reading.
MergePolygons2 overloads
public static Reckfell.Collections.Array<Vector2[]> MergePolygons(Vector2[] polygonA, Vector2[] polygonB);EvenOdd union A∪B. Returns contours, possibly multiple outer boundaries and holes; neither one result nor stable ordering is guaranteed.
| Name | Type | Default |
|---|---|---|
polygonA | Vector2[] | — |
polygonB | Vector2[] | — |
polygonAOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
polygonBOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
public static Reckfell.Collections.Array<Vector2[]> MergePolygons(ReadOnlySpan<Vector2> polygonA, ReadOnlySpan<Vector2> polygonB);EvenOdd union A∪B. Returns contours, possibly multiple outer boundaries and holes; neither one result nor stable ordering is guaranteed.
| Name | Type | Default |
|---|---|---|
polygonA | ReadOnlySpan<Vector2> | — |
polygonB | ReadOnlySpan<Vector2> | — |
polygonAOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
polygonBOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
OffsetPolygon2 overloads
public static Reckfell.Collections.Array<Vector2[]> OffsetPolygon(Vector2[] polygon, float delta, Geometry2D.PolyJoinType joinType = Geometry2D.PolyJoinType.Square);Offsets a closed region: positive delta expands, negative contracts and can remove or split it. Default join is Square; Miter uses the current 2.0 miter limit and Round is approximated. Span overload requires explicit joinType.
| Name | Type | Default |
|---|---|---|
polygon | Vector2[] | — |
delta | float | — |
joinType | Geometry2D.PolyJoinType | Geometry2D.PolyJoinType.Square |
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
deltaSigned boundary offset in point units: positive expands, negative contracts.
joinTypeSquare, Round or Miter joins; Round is approximate and sharp Miters are limited.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
public static Reckfell.Collections.Array<Vector2[]> OffsetPolygon(ReadOnlySpan<Vector2> polygon, float delta, Geometry2D.PolyJoinType joinType);Offsets a closed region: positive delta expands, negative contracts and can remove or split it. Default join is Square; Miter uses the current 2.0 miter limit and Round is approximated. Span overload requires explicit joinType.
| Name | Type | Default |
|---|---|---|
polygon | ReadOnlySpan<Vector2> | — |
delta | float | — |
joinType | Geometry2D.PolyJoinType | — |
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
deltaSigned boundary offset in point units: positive expands, negative contracts.
joinTypeSquare, Round or Miter joins; Round is approximate and sharp Miters are limited.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
OffsetPolyline2 overloads
public static Reckfell.Collections.Array<Vector2[]> OffsetPolyline(Vector2[] polyline, float delta, Geometry2D.PolyJoinType joinType = Geometry2D.PolyJoinType.Square, Geometry2D.PolyEndType endType = Geometry2D.PolyEndType.Square);Creates polygonal stroke contours around an open line with half-width abs(delta). Current Clipper2 uses positive width for negative values rather than returning empty. Square caps extend beyond endpoints; Butt stops at them. EndType.Polygon is diagnosed: use OffsetPolygon. Span overload requires both enums explicitly.
| Name | Type | Default |
|---|---|---|
polyline | Vector2[] | — |
delta | float | — |
joinType | Geometry2D.PolyJoinType | Geometry2D.PolyJoinType.Square |
endType | Geometry2D.PolyEndType | Geometry2D.PolyEndType.Square |
polylineOrdered open-line vertices, normally at least two distinct points.
deltaStroke half-width in point units; current open offset uses abs(delta).
joinTypeSquare, Round or Miter joins; Round is approximate and sharp Miters are limited.
endTypeButt/Square/Round or Joined; Polygon is invalid for OffsetPolyline. Joined connects line ends without making it an ordinary filled input region.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
public static Reckfell.Collections.Array<Vector2[]> OffsetPolyline(ReadOnlySpan<Vector2> polyline, float delta, Geometry2D.PolyJoinType joinType, Geometry2D.PolyEndType endType);Creates polygonal stroke contours around an open line with half-width abs(delta). Current Clipper2 uses positive width for negative values rather than returning empty. Square caps extend beyond endpoints; Butt stops at them. EndType.Polygon is diagnosed: use OffsetPolygon. Span overload requires both enums explicitly.
| Name | Type | Default |
|---|---|---|
polyline | ReadOnlySpan<Vector2> | — |
delta | float | — |
joinType | Geometry2D.PolyJoinType | — |
endType | Geometry2D.PolyEndType | — |
polylineOrdered open-line vertices, normally at least two distinct points.
deltaStroke half-width in point units; current open offset uses abs(delta).
joinTypeSquare, Round or Miter joins; Round is approximate and sharp Miters are limited.
endTypeButt/Square/Round or Joined; Polygon is invalid for OffsetPolyline. Joined connects line ends without making it an ordinary filled input region.
Reckfell.Collections.Array<Vector2[]>Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.
PointIsInsideTrianglebool
public static bool PointIsInsideTriangle(Vector2 point, Vector2 a, Vector2 b, Vector2 c);Tests cross-product signs. Interior points work with either winding, but edge inclusion depends on winding. Neither a consistent boundary classifier nor degeneracy validation.
| Name | Type | Default |
|---|---|---|
point | Vector2 | — |
a | Vector2 | — |
b | Vector2 | — |
c | Vector2 | — |
pointQuery point in the same coordinates as the geometry.
aVertex a of a nondegenerate triangle; define a separate boundary-inclusion policy.
bVertex b of a nondegenerate triangle; define a separate boundary-inclusion policy.
cVertex c of a nondegenerate triangle; define a separate boundary-inclusion policy.
boolBoolean result subject to the boundary rules in the method description.
SegmentIntersectsCirclefloat
public static float SegmentIntersectsCircle(Vector2 segmentFrom, Vector2 segmentTo, Vector2 circlePosition, float circleRadius);Returns the first accepted intersection root in 0…1, otherwise -1. Outside starts give entry, inside starts may give exit; tangency is included. Requires a nonzero segment: solves a quadratic dividing by squared length, not a universal point-in-circle test.
| Name | Type | Default |
|---|---|---|
segmentFrom | Vector2 | — |
segmentTo | Vector2 | — |
circlePosition | Vector2 | — |
circleRadius | float | — |
segmentFromPoint in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
segmentToPoint in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
circlePositionCircle center in common coordinates.
circleRadiusNonnegative finite radius in point units.
floatFraction t in 0…1 or -1; position is segmentFrom.Lerp(segmentTo,t).
SegmentIntersectsSegmentVariant
public static Variant SegmentIntersectsSegment(Vector2 fromA, Vector2 toA, Vector2 fromB, Vector2 toB);Finds one intersection of finite segments, allowing shared endpoints when nonparallel. Collinear overlap and a degenerate first segment yield no result; Nil is not a general proof of no shared region.
| Name | Type | Default |
|---|---|---|
fromA | Vector2 | — |
toA | Vector2 | — |
fromB | Vector2 | — |
toB | Vector2 | — |
fromAPoint in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
toAPoint in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
fromBPoint in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
toBPoint in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.
VariantVariant containing Vector2 or Nil; dispose after use and do not treat (0,0) as a miss sentinel.
TriangulateDelaunay2 overloads
public static int[] TriangulateDelaunay(Vector2[] points);Delaunay-triangulates a point cloud. Input order does not define a constrained concave boundary; outer/inner constraints and holes are not preserved automatically. Indices come in triples into original points.
| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
pointsFinite Vector2 cloud in common coordinates; Delaunay needs nondegenerate noncollinear data.
int[]int[] of triangle index triples into the input array; can be empty when no triangulation is produced.
public static int[] TriangulateDelaunay(ReadOnlySpan<Vector2> points);Delaunay-triangulates a point cloud. Input order does not define a constrained concave boundary; outer/inner constraints and holes are not preserved automatically. Indices come in triples into original points.
| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
pointsFinite Vector2 cloud in common coordinates; Delaunay needs nondegenerate noncollinear data.
int[]int[] of triangle index triples into the input array; can be empty when no triangulation is produced.
TriangulatePolygon2 overloads
public static int[] TriangulatePolygon(Vector2[] polygon);Triangulates one simple ordered contour without a separate hole set. Returns original vertex indices in triples; failure gives empty. It can relax checks for collinear points and emit zero-area triangles: output is not a quality validator.
| Name | Type | Default |
|---|---|---|
polygon | Vector2[] | — |
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
int[]int[] of triangle index triples into the input array; can be empty when no triangulation is produced.
public static int[] TriangulatePolygon(ReadOnlySpan<Vector2> polygon);Triangulates one simple ordered contour without a separate hole set. Returns original vertex indices in triples; failure gives empty. It can relax checks for collinear points and emit zero-area triangles: output is not a quality validator.
| Name | Type | Default |
|---|---|---|
polygon | ReadOnlySpan<Vector2> | — |
polygonOrdered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.
int[]int[] of triangle index triples into the input array; can be empty when no triangulation is produced.
Geometry2D.PolyBooleanOperation
| Value | Description |
|---|---|
Difference = 1 | Create regions where subject polygons are filled except where clip polygons are filled. |
Intersection = 2 | Create regions where both subject and clip polygons are filled. |
Union = 0 | Create regions where either subject or clip polygons (or both) are filled. |
Xor = 3 | Create regions where either subject or clip polygons are filled but not where both are filled. |
Geometry2D.PolyEndType
| Value | Description |
|---|---|
Butt = 2 | Endpoints are squared off with no extension. |
Joined = 1 | Endpoints are joined using the |
Polygon = 0 | Endpoints are joined using the |
Round = 4 | Endpoints are rounded off and extended by |
Square = 3 | Endpoints are squared off and extended by |
Geometry2D.PolyJoinType
| Value | Description |
|---|---|
Miter = 2 | There's a necessary limit to mitered joins since offsetting edges that join at very acute angles will produce excessively long and narrow "spikes". For any given edge join, when miter offsetting would exceed that maximum distance, "square" joining is applied. |
Round = 1 | While flattened paths can never perfectly trace an arc, they are approximated by a series of arc chords. |
Square = 0 | Squaring is applied uniformally at all convex edge joins at |