reckfellENGINE

Geometry3D

Analytic 3D geometry: intersections, planes, clipping and tetrahedra.

On this page
class Geometry3DReckfellSharp

Static CPU operations on supplied coordinates. They neither query game-world objects nor use CollisionLayer/CollisionMask or automatically create meshes/collisions. Use one coordinate system for all inputs; apply local/world transforms yourself. Singleton is a borrowed engine service and must not be disposed.

A ray takes an origin and direction; a segment takes two endpoints. RayIntersectsTriangle and SegmentIntersectsTriangle return a Variant: Vector3 on hit, Nil on miss. Do not use Vector3.Zero as a miss sentinel because the origin can be a valid hit position.

C#
using Variant hit = Geometry3D.RayIntersectsTriangle(
    new Vector3(0.25f, 0.25f, 1), new Vector3(0, 0, -1),
    Vector3.Zero, new Vector3(1, 0, 0), new Vector3(0, 1, 0));
if (hit.VariantType == Variant.Type.Vector3)
{
    Vector3 position = hit.AsVector3();
}

SegmentIntersectsSphere/Cylinder/Convex return two Vector3 values: [position, normal], not entry and exit. An empty array means no accepted intersection. These are not universal containment tests: sphere and convex queries starting inside return no exit, while cylinder can return the starting point with a zero normal. Exact sphere tangency is excluded. Triangle segments exclude the starting point with a tolerance but include the endpoint; rays also apply a positive parameter cutoff.

BuildBoxPlanes takes half-extents; BuildCylinderPlanes takes full height. BuildCapsulePlanes uses the central cylindrical-section height, making total axial size height+2*radius. This differs from full-height semantics in some collision resources. Cylinder/capsule builders default to the Z axis. Builders return planes rather than ready Mesh/Shape objects.

GetTriangleBarycentricCoords returns a/b/c weights of the projection onto the triangle plane: positive weights do not establish that the original point lies in that plane. ClipPolygon retains the negative Plane halfspace with boundary tolerance; it does not turn an arbitrary unordered point set into a valid polygon. TetrahedralizeDelaunay returns groups of four indices into the original array rather than triangles or a decomposition of an arbitrary mesh with cavities.

34 Windows headless checks covered simple valid shapes, hits/misses, boundary behavior, result layouts and array/span overloads. Arbitrary topology, extreme-scale accuracy, large-data performance, physics-world queries and rendering were not accepted by this suite.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Properties1

SingletonProperty
# Singleton
C#
public static Geometry3DInstance Singleton { get; }

Borrowed Geometry3DInstance behind static API. Do not Free/Dispose it; calculations require no user-created instance.

Methods18

BuildBoxPlanesReckfell.Collections.Array<Plane>
# BuildBoxPlanes
C#
public static Reckfell.Collections.Array<Plane> BuildBoxPlanes(Vector3 extents);

Returns six planes of an origin-centered axis-aligned box with outward unit normals. extents are half sizes rather than full dimensions. Interior satisfies normal.Dot(point) ≤ D.

Parameters
NameTypeDefault
extentsVector3—
extents

Positive X/Y/Z half sizes, centered at the origin.

Returns Reckfell.Collections.Array<Plane>

Array<Plane> of six outward planes, not a Shape3D.

BuildCapsulePlanesReckfell.Collections.Array<Plane>
# BuildCapsulePlanes
C#
public static Reckfell.Collections.Array<Plane> BuildCapsulePlanes(float radius, float height, int sides, int lats, Vector3.Axis axis = Vector3.Axis.Z);

Builds a capsule plane approximation: sides*(1+2*lats) planes for valid positive parameters. height is central-section length; axial extremes are ±(height/2+radius). Intermediate latitude normals use normalized interpolation rather than uniform angular steps.

Parameters
NameTypeDefault
radiusfloat—
heightfloat—
sidesint—
latsint—
axisVector3.AxisVector3.Axis.Z
radius

Positive finite radius in the same units as the points.

height

Nonnegative capsule middle-section length; total height is height+2*radius.

sides

Side-direction count, use at least 3; not a world-unit tolerance.

lats

Positive hemisphere subdivision count controlling plane count.

axis

X/Y/Z axis; defaults to Z, not an arbitrary Vector3 direction.

Returns Reckfell.Collections.Array<Plane>

Array<Plane> approximation rather than a mesh; pole planes can repeat.

BuildCylinderPlanesReckfell.Collections.Array<Plane>
# BuildCylinderPlanes
C#
public static Reckfell.Collections.Array<Plane> BuildCylinderPlanes(float radius, float height, int sides, Vector3.Axis axis = Vector3.Axis.Z);

Returns sides lateral planes plus two caps for an approximate origin-centered convex cylinder. height is full height with caps at ±height/2; axis defaults to Z. A plane approximation rather than a smooth CylinderShape3D.

Parameters
NameTypeDefault
radiusfloat—
heightfloat—
sidesint—
axisVector3.AxisVector3.Axis.Z
radius

Positive finite radius in the same units as the points.

height

Positive full height with caps at ±height/2.

sides

Side-direction count, use at least 3; not a world-unit tolerance.

axis

X/Y/Z axis; defaults to Z, not an arbitrary Vector3 direction.

Returns Reckfell.Collections.Array<Plane>

Array<Plane>: sides lateral planes plus two caps.

ClipPolygon2 overloads
# ClipPolygon · 1/2
C#
public static Vector3[] ClipPolygon(Vector3[] points, Plane plane);

Clips an ordered planar polygon, retaining the negative side and tolerance boundary. Last-to-first edge closes the polygon; repeating the first vertex at the end is unnecessary. Validates neither self-intersection nor planarity and creates no volume cap. Array/span overloads share semantics and leave input unchanged.

Parameters
NameTypeDefault
pointsVector3[]—
planePlane—
points

Ordered planar-polygon vertices without a required closing duplicate; at least 3 for an ordinary region.

plane

Normalized Plane; retains normal.Dot(point)-D ≤ tolerance.

Returns Vector3[]

New Vector3[] of retained vertices/intersections; empty when fully clipped.

# ClipPolygon · 2/2
C#
public static Vector3[] ClipPolygon(ReadOnlySpan<Vector3> points, Plane plane);

Clips an ordered planar polygon, retaining the negative side and tolerance boundary. Last-to-first edge closes the polygon; repeating the first vertex at the end is unnecessary. Validates neither self-intersection nor planarity and creates no volume cap. Array/span overloads share semantics and leave input unchanged.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector3>—
planePlane—
points

Ordered planar-polygon vertices without a required closing duplicate; at least 3 for an ordinary region.

plane

Normalized Plane; retains normal.Dot(point)-D ≤ tolerance.

Returns Vector3[]

New Vector3[] of retained vertices/intersections; empty when fully clipped.

ComputeConvexMeshPointsVector3[]
# ComputeConvexMeshPoints
C#
public static Vector3[] ComputeConvexMeshPoints(Reckfell.Collections.Array<Plane> planes);

Finds triple-plane intersections not excluded by remaining normal.Dot(point) ≤ D halfspaces with tolerance. Returns no faces/indices and does not deduplicate all vertices. Requires valid normalized outward planes; this is not a convex hull builder for an arbitrary point cloud.

Parameters
NameTypeDefault
planesReckfell.Collections.Array<Plane>—
planes

Valid normalized outward Planes of a closed convex region, all in one coordinate system.

Returns Vector3[]

Vector3 intersections, possibly empty or duplicated, without face topology.

GetClosestPointToSegmentVector3
# GetClosestPointToSegment
C#
public static Vector3 GetClosestPointToSegment(Vector3 point, Vector3 s1, Vector3 s2);

Projects point onto the segment and clamps to its endpoints. Returns s1 for a near-zero-length segment. Does not return distance; measure from point to the result.

Parameters
NameTypeDefault
pointVector3—
s1Vector3—
s2Vector3—
point

Projection point in the same coordinates as s1/s2.

s1

Endpoint of the corresponding segment; for Uncapped the endpoints define an infinite line.

s2

Endpoint of the corresponding segment; for Uncapped the endpoints define an infinite line.

Returns Vector3

Point on the finite segment, including endpoints.

GetClosestPointToSegmentUncappedVector3
# GetClosestPointToSegmentUncapped
C#
public static Vector3 GetClosestPointToSegmentUncapped(Vector3 point, Vector3 s1, Vector3 s2);

Projects onto the infinite line through s1/s2 without endpoint clamping. Near-coincident endpoints return s1. Does not find a closest surface point.

Parameters
NameTypeDefault
pointVector3—
s1Vector3—
s2Vector3—
point

Projection point in the same coordinates as s1/s2.

s1

Endpoint of the corresponding segment; for Uncapped the endpoints define an infinite line.

s2

Endpoint of the corresponding segment; for Uncapped the endpoints define an infinite line.

Returns Vector3

Point on the infinite line, or s1 for degeneracy.

GetClosestPointsBetweenSegmentsVector3[]
# GetClosestPointsBetweenSegments
C#
public static Vector3[] GetClosestPointsBetweenSegments(Vector3 p1, Vector3 p2, Vector3 q1, Vector3 q2);

Returns one closest point per finite segment: first p1–p2, then q1–q2. Neither two intersections nor a scalar distance. Parallel/overlapping spans may admit multiple equally close pairs.

Parameters
NameTypeDefault
p1Vector3—
p2Vector3—
q1Vector3—
q2Vector3—
p1

Endpoint of the corresponding segment; for Uncapped the endpoints define an infinite line.

p2

Endpoint of the corresponding segment; for Uncapped the endpoints define an infinite line.

q1

Endpoint of the corresponding segment; for Uncapped the endpoints define an infinite line.

q2

Endpoint of the corresponding segment; for Uncapped the endpoints define an infinite line.

Returns Vector3[]

Two Vector3 values: first-segment point, then second-segment point.

GetTriangleBarycentricCoordsVector3
# GetTriangleBarycentricCoords
C#
public static Vector3 GetTriangleBarycentricCoords(Vector3 point, Vector3 a, Vector3 b, Vector3 c);

Computes a/b/c weights of the projection of point onto the triangle plane. Neither clamps weights to 0…1 nor checks point-to-plane distance. An exactly zero denominator returns Vector3.Zero; validate degeneracy separately.

Parameters
NameTypeDefault
pointVector3—
aVector3—
bVector3—
cVector3—
point

Query point; for barycentric use separately check its distance to the triangle plane.

a

Vertex a of a nondegenerate triangle in the common coordinate system.

b

Vertex b of a nondegenerate triangle in the common coordinate system.

c

Vertex c of a nondegenerate triangle in the common coordinate system.

Returns Vector3

Vector3 of a/b/c weights; Vector3.Zero also denotes a degenerate triangle.

RayIntersectsTriangleVariant
# RayIntersectsTriangle
C#
public static Variant RayIntersectsTriangle(Vector3 from, Vector3 dir, Vector3 a, Vector3 b, Vector3 c);

Intersects a forward infinite ray with either triangle side. dir is a direction rather than an endpoint. Parallel checks use tolerance; hits require parameter t > 0.00001. Normalize direction for a meaningful tolerance scale. Returns a Vector3/Nil Variant.

Parameters
NameTypeDefault
fromVector3—
dirVector3—
aVector3—
bVector3—
cVector3—
from

Ray/segment origin in the common coordinate system.

dir

Nonzero ray direction rather than a to endpoint; normally normalized.

a

Vertex a of a nondegenerate triangle in the common coordinate system.

b

Vertex b of a nondegenerate triangle in the common coordinate system.

c

Vertex c of a nondegenerate triangle in the common coordinate system.

Returns Variant

Caller-owned Variant containing Vector3 or Nil. Dispose after checking its type.

SegmentIntersectsConvex2 overloads
# SegmentIntersectsConvex · 1/2
C#
public static Vector3[] SegmentIntersectsConvex(Vector3 from, Vector3 to, Reckfell.Collections.Array planes);

Finds segment entry into normalized outward-Plane halfspaces normal.Dot(point) ≤ D. Inside starts/zero-length segments do not yield an exit. Returns [entry position, entry-plane normal] or empty. Untyped-overload elements must still be Plane; its adapter creates Array<Plane>.

Parameters
NameTypeDefault
fromVector3—
toVector3—
planesReckfell.Collections.Array—
from

Ray/segment origin in the common coordinate system.

to

Segment endpoint rather than a direction.

planes

Valid normalized outward Planes of a closed convex region, all in one coordinate system.

Returns Vector3[]

Empty or [entry position, plane normal]; no exit is returned.

# SegmentIntersectsConvex · 2/2
C#
public static Vector3[] SegmentIntersectsConvex(Vector3 from, Vector3 to, Reckfell.Collections.Array<Plane> planes);

Finds segment entry into normalized outward-Plane halfspaces normal.Dot(point) ≤ D. Inside starts/zero-length segments do not yield an exit. Returns [entry position, entry-plane normal] or empty. Untyped-overload elements must still be Plane; its adapter creates Array<Plane>.

Parameters
NameTypeDefault
fromVector3—
toVector3—
planesReckfell.Collections.Array<Plane>—
from

Ray/segment origin in the common coordinate system.

to

Segment endpoint rather than a direction.

planes

Valid normalized outward Planes of a closed convex region, all in one coordinate system.

Returns Vector3[]

Empty or [entry position, plane normal]; no exit is returned.

SegmentIntersectsCylinderVector3[]
# SegmentIntersectsCylinder
C#
public static Vector3[] SegmentIntersectsCylinder(Vector3 from, Vector3 to, float height, float radius);

Intersects a finite segment with an origin-centered Z-axis cylinder; height is full height and radius is radial. No axis/position argument: transform endpoints into local space yourself. Inside starts can return from with a zero/non-surface normal; this is not an exit intersection.

Parameters
NameTypeDefault
fromVector3—
toVector3—
heightfloat—
radiusfloat—
from

Ray/segment origin in the common coordinate system.

to

Segment endpoint rather than a direction.

height

Positive full height with caps at ±height/2.

radius

Positive finite radius in the same units as the points.

Returns Vector3[]

Empty or [position, normal]; inside starts can have a zero normal.

SegmentIntersectsSphereVector3[]
# SegmentIntersectsSphere
C#
public static Vector3[] SegmentIntersectsSphere(Vector3 from, Vector3 to, Vector3 spherePosition, float sphereRadius);

Finds the forward entry of a segment into a sphere. Excludes exact tangency and near-zero segments. Starting inside places entry behind the origin, so no exit is returned. Success gives [position, outward normal], otherwise empty.

Parameters
NameTypeDefault
fromVector3—
toVector3—
spherePositionVector3—
sphereRadiusfloat—
from

Ray/segment origin in the common coordinate system.

to

Segment endpoint rather than a direction.

spherePosition

Sphere center in the same coordinates as from/to.

sphereRadius

Positive finite radius in the same units as the points.

Returns Vector3[]

Empty Vector3[] or exactly [position, normal], not two surface points.

SegmentIntersectsTriangleVariant
# SegmentIntersectsTriangle
C#
public static Variant SegmentIntersectsTriangle(Vector3 from, Vector3 to, Vector3 a, Vector3 b, Vector3 c);

Intersects finite from→to with either triangle side. Parameter must exceed CMP_EPSILON and be at most 1: start excluded, endpoint allowed. Returns neither normal, UV nor triangle index; result is a Vector3/Nil Variant.

Parameters
NameTypeDefault
fromVector3—
toVector3—
aVector3—
bVector3—
cVector3—
from

Ray/segment origin in the common coordinate system.

to

Segment endpoint rather than a direction.

a

Vertex a of a nondegenerate triangle in the common coordinate system.

b

Vertex b of a nondegenerate triangle in the common coordinate system.

c

Vertex c of a nondegenerate triangle in the common coordinate system.

Returns Variant

Variant containing a Vector3 hit or Nil; caller disposes the Variant.

TetrahedralizeDelaunay2 overloads
# TetrahedralizeDelaunay · 1/2
C#
public static int[] TetrahedralizeDelaunay(Vector3[] points);

Builds Delaunay tetrahedra for a volumetric point cloud, returning original indices in groups of four. Neither triangle faces nor a constrained decomposition of a mesh with holes. Supply finite nondegenerate 3D data; index order/orientation and extreme-scale robustness are not established contracts.

Parameters
NameTypeDefault
pointsVector3[]—
points

Finite volumetric Vector3 cloud with at least four nondegenerate points; not mesh indices.

Returns int[]

int[] indices into original points; each group of four describes a tetrahedron. Empty output does not establish valid input.

# TetrahedralizeDelaunay · 2/2
C#
public static int[] TetrahedralizeDelaunay(ReadOnlySpan<Vector3> points);

Builds Delaunay tetrahedra for a volumetric point cloud, returning original indices in groups of four. Neither triangle faces nor a constrained decomposition of a mesh with holes. Supply finite nondegenerate 3D data; index order/orientation and extreme-scale robustness are not established contracts.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector3>—
points

Finite volumetric Vector3 cloud with at least four nondegenerate points; not mesh indices.

Returns int[]

int[] indices into original points; each group of four describes a tetrahedron. Empty output does not establish valid input.

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.