reckfellENGINE

Geometry2D

Analytic 2D geometry, contour operations and rectangle packing.

On this page
class Geometry2DReckfellSharp

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.

C#
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
# Singleton
C#
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>
# BresenhamLine
C#
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.

Parameters
NameTypeDefault
fromVector2I—
toVector2I—
from

Integer Bresenham endpoint; both ends are included.

to

Integer Bresenham endpoint; both ends are included.

Returns Reckfell.Collections.Array<Vector2I>

Array<Vector2I> of ordered cells from from to to inclusive.

ClipPolygons2 overloads
# ClipPolygons · 1/2
C#
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.

Parameters
NameTypeDefault
polygonAVector2[]—
polygonBVector2[]—
polygonA

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

polygonB

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

# ClipPolygons · 2/2
C#
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.

Parameters
NameTypeDefault
polygonAReadOnlySpan<Vector2>—
polygonBReadOnlySpan<Vector2>—
polygonA

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

polygonB

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

ClipPolylineWithPolygon2 overloads
# ClipPolylineWithPolygon · 1/2
C#
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.

Parameters
NameTypeDefault
polylineVector2[]—
polygonVector2[]—
polyline

Ordered open-line vertices, normally at least two distinct points.

polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> of open fragments, possibly empty.

# ClipPolylineWithPolygon · 2/2
C#
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.

Parameters
NameTypeDefault
polylineReadOnlySpan<Vector2>—
polygonReadOnlySpan<Vector2>—
polyline

Ordered open-line vertices, normally at least two distinct points.

polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> of open fragments, possibly empty.

ConvexHull2 overloads
# ConvexHull · 1/2
C#
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.

Parameters
NameTypeDefault
pointsVector2[]—
points

Finite Vector2 cloud in common coordinates; Delaunay needs nondegenerate noncollinear data.

Returns Vector2[]

Vector2[] hull with a closing duplicate for ordinary nondegenerate input.

# ConvexHull · 2/2
C#
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.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector2>—
points

Finite Vector2 cloud in common coordinates; Delaunay needs nondegenerate noncollinear data.

Returns Vector2[]

Vector2[] hull with a closing duplicate for ordinary nondegenerate input.

DecomposePolygonInConvex2 overloads
# DecomposePolygonInConvex · 1/2
C#
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.

Parameters
NameTypeDefault
polygonVector2[]—
polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> of convex parts of one polygon; failure can yield empty. This input does not specify separate hole rings.

# DecomposePolygonInConvex · 2/2
C#
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.

Parameters
NameTypeDefault
polygonReadOnlySpan<Vector2>—
polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns 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
# ExcludePolygons · 1/2
C#
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.

Parameters
NameTypeDefault
polygonAVector2[]—
polygonBVector2[]—
polygonA

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

polygonB

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

# ExcludePolygons · 2/2
C#
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.

Parameters
NameTypeDefault
polygonAReadOnlySpan<Vector2>—
polygonBReadOnlySpan<Vector2>—
polygonA

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

polygonB

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

GetClosestPointToSegmentVector2
# GetClosestPointToSegment
C#
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.

Parameters
NameTypeDefault
pointVector2—
s1Vector2—
s2Vector2—
point

Query point in the same coordinates as the geometry.

s1

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

s2

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

Returns Vector2

Projected Vector2 rather than distance.

GetClosestPointToSegmentUncappedVector2
# GetClosestPointToSegmentUncapped
C#
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.

Parameters
NameTypeDefault
pointVector2—
s1Vector2—
s2Vector2—
point

Query point in the same coordinates as the geometry.

s1

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

s2

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

Returns Vector2

Projected Vector2 rather than distance.

GetClosestPointsBetweenSegmentsVector2[]
# GetClosestPointsBetweenSegments
C#
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.

Parameters
NameTypeDefault
p1Vector2—
q1Vector2—
p2Vector2—
q2Vector2—
p1

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

q1

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

p2

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

q2

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

Returns Vector2[]

Two Vector2 values: point on p1–q1, then p2–q2.

IntersectPolygons2 overloads
# IntersectPolygons · 1/2
C#
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.

Parameters
NameTypeDefault
polygonAVector2[]—
polygonBVector2[]—
polygonA

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

polygonB

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

# IntersectPolygons · 2/2
C#
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.

Parameters
NameTypeDefault
polygonAReadOnlySpan<Vector2>—
polygonBReadOnlySpan<Vector2>—
polygonA

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

polygonB

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

IntersectPolylineWithPolygon2 overloads
# IntersectPolylineWithPolygon · 1/2
C#
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.

Parameters
NameTypeDefault
polylineVector2[]—
polygonVector2[]—
polyline

Ordered open-line vertices, normally at least two distinct points.

polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> of open fragments, possibly empty.

# IntersectPolylineWithPolygon · 2/2
C#
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.

Parameters
NameTypeDefault
polylineReadOnlySpan<Vector2>—
polygonReadOnlySpan<Vector2>—
polyline

Ordered open-line vertices, normally at least two distinct points.

polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> of open fragments, possibly empty.

IsPointInCirclebool
# IsPointInCircle
C#
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.

Parameters
NameTypeDefault
pointVector2—
circlePositionVector2—
circleRadiusfloat—
point

Query point in the same coordinates as the geometry.

circlePosition

Circle center in common coordinates.

circleRadius

Nonnegative finite radius in point units.

Returns bool

Boolean result subject to the boundary rules in the method description.

IsPointInPolygon2 overloads
# IsPointInPolygon · 1/2
C#
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.

Parameters
NameTypeDefault
pointVector2—
polygonVector2[]—
point

Query point in the same coordinates as the geometry.

polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns bool

Boolean result subject to the boundary rules in the method description.

# IsPointInPolygon · 2/2
C#
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.

Parameters
NameTypeDefault
pointVector2—
polygonReadOnlySpan<Vector2>—
point

Query point in the same coordinates as the geometry.

polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns bool

Boolean result subject to the boundary rules in the method description.

IsPolygonClockwise2 overloads
# IsPolygonClockwise · 1/2
C#
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.

Parameters
NameTypeDefault
polygonVector2[]—
polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns bool

Boolean result subject to the boundary rules in the method description.

# IsPolygonClockwise · 2/2
C#
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.

Parameters
NameTypeDefault
polygonReadOnlySpan<Vector2>—
polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns bool

Boolean result subject to the boundary rules in the method description.

LineIntersectsLineVariant
# LineIntersectsLine
C#
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.

Parameters
NameTypeDefault
fromAVector2—
dirAVector2—
fromBVector2—
dirBVector2—
fromA

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

dirA

Nonzero infinite-line direction rather than a second endpoint.

fromB

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

dirB

Nonzero infinite-line direction rather than a second endpoint.

Returns Variant

Variant containing Vector2 or Nil; dispose after use and do not treat (0,0) as a miss sentinel.

MakeAtlas2 overloads
# MakeAtlas · 1/2
C#
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.

Parameters
NameTypeDefault
sizesVector2[]—
sizes

Nonempty positive integer sizes, each width ≤4096; fractions truncate and can become zero.

Returns Reckfell.Collections.Dictionary

Owned Dictionary: points is a Vector2[] of placements in original-index order; size is total Vector2I dimensions. Dispose the dictionary after reading.

# MakeAtlas · 2/2
C#
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.

Parameters
NameTypeDefault
sizesReadOnlySpan<Vector2>—
sizes

Nonempty positive integer sizes, each width ≤4096; fractions truncate and can become zero.

Returns Reckfell.Collections.Dictionary

Owned Dictionary: points is a Vector2[] of placements in original-index order; size is total Vector2I dimensions. Dispose the dictionary after reading.

MergePolygons2 overloads
# MergePolygons · 1/2
C#
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.

Parameters
NameTypeDefault
polygonAVector2[]—
polygonBVector2[]—
polygonA

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

polygonB

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

# MergePolygons · 2/2
C#
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.

Parameters
NameTypeDefault
polygonAReadOnlySpan<Vector2>—
polygonBReadOnlySpan<Vector2>—
polygonA

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

polygonB

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

OffsetPolygon2 overloads
# OffsetPolygon · 1/2
C#
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.

Parameters
NameTypeDefault
polygonVector2[]—
deltafloat—
joinTypeGeometry2D.PolyJoinTypeGeometry2D.PolyJoinType.Square
polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

delta

Signed boundary offset in point units: positive expands, negative contracts.

joinType

Square, Round or Miter joins; Round is approximate and sharp Miters are limited.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

# OffsetPolygon · 2/2
C#
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.

Parameters
NameTypeDefault
polygonReadOnlySpan<Vector2>—
deltafloat—
joinTypeGeometry2D.PolyJoinType—
polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

delta

Signed boundary offset in point units: positive expands, negative contracts.

joinType

Square, Round or Miter joins; Round is approximate and sharp Miters are limited.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

OffsetPolyline2 overloads
# OffsetPolyline · 1/2
C#
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.

Parameters
NameTypeDefault
polylineVector2[]—
deltafloat—
joinTypeGeometry2D.PolyJoinTypeGeometry2D.PolyJoinType.Square
endTypeGeometry2D.PolyEndTypeGeometry2D.PolyEndType.Square
polyline

Ordered open-line vertices, normally at least two distinct points.

delta

Stroke half-width in point units; current open offset uses abs(delta).

joinType

Square, Round or Miter joins; Round is approximate and sharp Miters are limited.

endType

Butt/Square/Round or Joined; Polygon is invalid for OffsetPolyline. Joined connects line ends without making it an ordinary filled input region.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

# OffsetPolyline · 2/2
C#
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.

Parameters
NameTypeDefault
polylineReadOnlySpan<Vector2>—
deltafloat—
joinTypeGeometry2D.PolyJoinType—
endTypeGeometry2D.PolyEndType—
polyline

Ordered open-line vertices, normally at least two distinct points.

delta

Stroke half-width in point units; current open offset uses abs(delta).

joinType

Square, Round or Miter joins; Round is approximate and sharp Miters are limited.

endType

Butt/Square/Round or Joined; Polygon is invalid for OffsetPolyline. Joined connects line ends without making it an ordinary filled input region.

Returns Reckfell.Collections.Array<Vector2[]>

Array<Vector2[]> contours, possibly empty or containing multiple parts/holes. Not a set of ready physics objects.

PointIsInsideTrianglebool
# PointIsInsideTriangle
C#
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.

Parameters
NameTypeDefault
pointVector2—
aVector2—
bVector2—
cVector2—
point

Query point in the same coordinates as the geometry.

a

Vertex a of a nondegenerate triangle; define a separate boundary-inclusion policy.

b

Vertex b of a nondegenerate triangle; define a separate boundary-inclusion policy.

c

Vertex c of a nondegenerate triangle; define a separate boundary-inclusion policy.

Returns bool

Boolean result subject to the boundary rules in the method description.

SegmentIntersectsCirclefloat
# SegmentIntersectsCircle
C#
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.

Parameters
NameTypeDefault
segmentFromVector2—
segmentToVector2—
circlePositionVector2—
circleRadiusfloat—
segmentFrom

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

segmentTo

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

circlePosition

Circle center in common coordinates.

circleRadius

Nonnegative finite radius in point units.

Returns float

Fraction t in 0…1 or -1; position is segmentFrom.Lerp(segmentTo,t).

SegmentIntersectsSegmentVariant
# SegmentIntersectsSegment
C#
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.

Parameters
NameTypeDefault
fromAVector2—
toAVector2—
fromBVector2—
toBVector2—
fromA

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

toA

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

fromB

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

toB

Point in common coordinates. GetClosestPointsBetweenSegments pairs are p1–q1 and p2–q2; LineIntersectsLine from is a point on its line.

Returns Variant

Variant containing Vector2 or Nil; dispose after use and do not treat (0,0) as a miss sentinel.

TriangulateDelaunay2 overloads
# TriangulateDelaunay · 1/2
C#
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.

Parameters
NameTypeDefault
pointsVector2[]—
points

Finite Vector2 cloud in common coordinates; Delaunay needs nondegenerate noncollinear data.

Returns int[]

int[] of triangle index triples into the input array; can be empty when no triangulation is produced.

# TriangulateDelaunay · 2/2
C#
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.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector2>—
points

Finite Vector2 cloud in common coordinates; Delaunay needs nondegenerate noncollinear data.

Returns int[]

int[] of triangle index triples into the input array; can be empty when no triangulation is produced.

TriangulatePolygon2 overloads
# TriangulatePolygon · 1/2
C#
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.

Parameters
NameTypeDefault
polygonVector2[]—
polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns int[]

int[] of triangle index triples into the input array; can be empty when no triangulation is produced.

# TriangulatePolygon · 2/2
C#
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.

Parameters
NameTypeDefault
polygonReadOnlySpan<Vector2>—
polygon

Ordered simple contour in common coordinates; omit a closing duplicate and do not combine separate rings.

Returns int[]

int[] of triangle index triples into the input array; can be empty when no triangulation is produced.

Geometry2D.PolyBooleanOperation

ValueDescription
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

ValueDescription
Butt = 2

Endpoints are squared off with no extension.

Joined = 1

Endpoints are joined using the Geometry2D.PolyJoinType value and the path filled as a polyline.

Polygon = 0

Endpoints are joined using the Geometry2D.PolyJoinType value and the path filled as a polygon.

Round = 4

Endpoints are rounded off and extended by delta units.

Square = 3

Endpoints are squared off and extended by delta units.

Geometry2D.PolyJoinType

ValueDescription
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 1 * delta.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.