Table of Contents

Namespace Thunder.UnitsNET.Vectors.Geometry

Classes

CatmullRomSpline2

A Catmull-Rom spline defined by an ordered sequence of LengthPoint2 waypoints that the curve passes through.

Unlike a Bézier curve, a Catmull-Rom spline passes through every supplied waypoint. This makes it well-suited for game AI paths, camera rails, and any use-case where control points are intended as actual pass-through positions.

Evaluate the spline with Evaluate(Ratio) using a normalized parameter t ∈ [0, 1] that maps uniformly across all segments. Use ToPath(int) to convert to an arc-length parameterised LengthPath2 for distance-based traversal.

Direction2Extensions

Extension methods for Direction2 that provide rotation helpers, angle measurements, and approximate-equality comparisons.

These are defined as extension methods rather than instance methods so they can be added to without modifying the core Direction2 struct.

DirectionComparer

An IEqualityComparer<T> for Direction2 that delegates to the built-in value equality of the Direction2 record struct.

Use this when you need to store Direction2 values in a collection that requires an explicit equality comparer — for example, a HashSet<T> or as the key in a Dictionary<TKey, TValue>.

For approximate equality (where floating-point drift is a concern) use ApproximatelyEquals(Direction2, Direction2, Angle) instead.

LengthPath2

An arc-length parameterised polyline defined by a sequence of LengthPoint2 waypoints.

Use Evaluate(Length) to convert a scalar arc-length distance into a world-space position, and TangentAt(Length) to get the forward direction at that point.

LengthVector2GeometryExtensions

Extension methods for LengthVector2 that require types from the Thunder.UnitsNET.Vectors.Geometry assembly (e.g. Direction2).

These cannot be instance methods on LengthVector2 because Thunder.UnitsNET.Vectors does not reference the Geometry assembly.

PhysicsIntegration

Pure utility methods for updating entity state each game tick. Codifies correct unit algebra for Euler/Verlet integration, drag, friction, and collision push-out.

Polygon2

An arbitrary polygon in 2D space, defined by an ordered list of vertices.

A polygon is a closed shape formed by connecting each vertex to the next with a straight line, and connecting the last vertex back to the first. The vertices can form any shape: convex (like a square or regular hexagon) or concave (like an L-shape or star).

All geometric properties — Area, Perimeter, Centroid, and IsConvex — are computed once during construction and cached.

Polygon2 is an immutable class (not a struct) because it stores a variable-length vertex list.

Structs

Arc2

A directed arc on a circle in 2D space: a curve tracing part of a circle's circumference from a start point to a target point in a specified direction (clockwise or counter-clockwise).

An arc is defined by three things:

  1. The Circle it lies on.
  2. A StartDirection — the direction from the circle's centre to the start of the arc.
  3. An ArcAngle — a signed sweep angle. Positive means counter-clockwise (CCW); negative means clockwise (CW).

From these, all other properties — StartPosition, TargetPosition, ArcLength, and TargetRay — are derived automatically.

Arc2 is a readonly record struct: value-type, immutable, and equality-by-value.

Arc direction follows standard mathematical convention: positive angles are counter-clockwise, negative are clockwise. See ArcDirection for important notes on how arc direction appears in MonoGame's Y-down coordinate system.
BezierCurve2

A cubic Bézier curve defined by four LengthPoint2 control points.

The curve passes through P0 at t = 0 and P3 at t = 1. P1 and P2 are tangent guides — the curve is attracted to them but does not (in general) pass through them.

Use Evaluate(Ratio) for an exact position at a given curve parameter, and ToPath(int) to convert to an arc-length parameterised LengthPath2 for distance-based traversal.

Capsule2

A capsule shape in 2D space: a rectangle with semicircular caps on both ends.

Think of a capsule as the set of all points within a given Radius of a line segment called the spine. The spine runs along the capsule's long axis, centred at Center, with half-length extending in both the capsule's Orientation direction and the opposite direction.

Practical analogy: a standard vitamin capsule, a pill, or a running-track outline.

Capsule2 is a readonly record struct: value-type, immutable, and equality-by-value.

Circle2

A circle in 2D space, defined by a centre point and a Radius.

Circle2 is a readonly record struct, so it is value-type, immutable, and can be compared for equality by value. All operations return new instances.

A circle is the set of all points whose distance from the centre equals the radius. This type lets you work with circles in unit-aware code: for example, you can check whether a real-world position lies inside a turn radius, or compute where a tangent from an external target touches the circle (useful for path-planning around obstacles).

CollisionManifold

Data returned by a successful collision test: how deeply two shapes overlap, which direction to push them apart, and where the contact occurs.

Diameter

A non-negative scalar wrapper over UnitsNet.Length representing a circle's diameter.

A Diameter is the full width of a circle: exactly twice the Radius. Like Radius, it enforces the non-negative constraint at construction time.

It implicitly converts to UnitsNet.Length for compatibility with APIs that accept raw lengths, and can be converted to a Radius via the Radius property.

Direction2

Represents a normalized 2D direction — a unit vector on the plane, combined with the angle it makes with the positive X-axis (measured counter-clockwise).

A Direction2 always stores its angle in the range [0°, 360°). The Direction is always a unit vector (magnitude 1). Both values are derived from each other: Direction = (cos θ, sin θ).

Use Direction2 when you need to express "which way something is facing" or "which way to move" independently of how far to move. Combine with a UnitsNet.Length or LengthVector2 to produce a displacement.

Ellipse2

A positioned, optionally-rotated ellipse in 2D space.

An ellipse is defined by a centre point, two semi-axes, and a rotation. The semi-major axis (a) is the half-length of the longest dimension; the semi-minor axis (b) is the half-length of the shortest. When both axes are equal the ellipse degenerates to a circle.

Rotation is expressed as a Direction2 that points along the positive end of the semi-major axis. At zero rotation (East) the major axis lies along +X and the minor axis along +Y.

Ellipse2 is a readonly record struct: value-type, immutable, and equality-by-value. All computed properties are derived on demand.

LengthLine2

Represents an infinite line in 2D space, defined by any point on the line and its direction.

Unlike a LengthSegment2, a line extends infinitely in both directions from its defining point. It is useful for intersection queries, perpendicular projections, and computing whether a point is to the left or right of a boundary.

LengthRay2

Represents a ray in 2D space — a half-line starting at a point (Position) and extending infinitely in one direction (Direction).

A ray is useful when direction and starting point matter but there is no fixed endpoint: projectile trajectories, line-of-sight checks, sensor cones, and raycasting all fit naturally into this type.

A ray can be converted to a finite LengthSegment2 via WithMagnitude(Length) and to an infinite LengthLine2 via AsLine().

LengthSegment2

Represents a directed line segment in 2D space defined by a start point and an end point.

A segment is the simplest linear primitive: it has a finite length, a direction, and two fixed endpoints. It is the building block for polygon edges, pathfinding corridors, and collision detection.

All properties are computed once at construction and stored. The type is immutable — use the secondary constructor or FromMeters(double, double, double, double) to create segments with different values.

Radius

A non-negative scalar wrapper over UnitsNet.Length representing a circle's radius.

Unlike a raw UnitsNet.Length, a Radius enforces the physical constraint that a radius cannot be negative. It also provides computed circle geometry (Circumference and Area) so you do not need a separate unpositioned "circle" type — the radius carries those properties directly.

Use Radius anywhere an API specifically expects a radial measurement (e.g. constructing a Circle2). It implicitly converts to UnitsNet.Length so it is interchangeable with raw lengths where needed.

RaycastHit

The result of a successful ray-shape intersection test.

Rectangle2

A positioned, optionally-rotated rectangle in 2D space, defined by its centre, dimensions (width × height), and orientation.

Rectangle2 is a readonly record struct: it is value-type, immutable, and supports equality by value. All computed properties (corners, area, etc.) are derived on demand from the three stored fields — no extra memory is used.

The axis-aligned case (no rotation) is the default. Rotation is expressed as a Direction2 that points in the "right" direction of the rectangle. At zero rotation (Zero), "right" is East (+X) and "up" is North (+Y), giving the familiar axis-aligned layout.

Sector2

A sector ("pie slice") of a circle in 2D space: the region bounded by two radii and the arc between them.

A sector is defined by:

  1. A Circle — provides centre and radius.
  2. A StartDirection — the direction from the centre to the start edge.
  3. An EndDirection — the direction from the centre to the end edge.
  4. A Direction — whether the sweep is clockwise (CW) or counter-clockwise (CCW).

From these, Area, ArcLength, Perimeter, and SweepAngle are computed automatically.

Sector2 is a readonly record struct: value-type, immutable, and equality-by-value.

Transform2

A 2D spatial transform composed of a position (Position), an orientation (Rotation), and a uniform scale (Scale).

Transform2 converts between local space (relative to the transform's origin) and world space. The order of operations when going local → world is: scale, then rotate, then translate.

Triangle2

A triangle in 2D space defined by three vertices A, B, and C.

Triangle2 is a readonly record struct: value-type, immutable, and comparable by value. All geometric properties (area, perimeter, centroid, sides) are computed from the three vertices.

Triangles are the fundamental building block of 2D geometry. You can use them to test point containment, compute signed areas, or approximate curved shapes as polygon fans. The vertex order determines orientation: counter-clockwise (CCW) is the positive convention, matching standard mathematical coordinates where Y increases upward.

Enums

ArcDirection

Specifies the direction in which an arc sweeps around its circle.

In standard 2D mathematical convention, counter-clockwise is the positive direction (increasing angle from the positive X-axis). Clockwise is the negative direction.

v0.7.0 ▼