Table of Contents

API Reference

Thunder.UnitsNET.Vectors is split across four packages, each covering a distinct layer. Use the namespace browser on the left to navigate to individual types, or jump directly using the table below.

Packages and namespaces

Package Namespace Purpose
Thunder.UnitsNET.Vectors Thunder.UnitsNET.Vectors Core unit-aware 2D/3D vector types
Thunder.UnitsNET.Vectors.MonoGame Thunder.UnitsNET.Vectors.MonoGame Core vector ↔ MonoGame/XNA conversions + Camera
Thunder.UnitsNET.Vectors.Geometry Thunder.UnitsNET.Vectors.Geometry Unit-aware 2D geometry shapes and transforms
Thunder.UnitsNET.Vectors.Geometry.MonoGame Thunder.UnitsNET.Vectors.Geometry.MonoGame Geometry ↔ MonoGame/XNA conversions + DebugDraw

Thunder.UnitsNET.Vectors

Unit-aware 2D and 3D vector types. Every component is a UnitsNet quantity, so operations preserve physical units automatically. Arithmetic between vector types produces the correct quantity type: LengthVector2 / Duration returns SpeedVector2; ForceVector2.Dot(LengthVector2) returns Energy.

Foundational types

Type Description
LengthPoint2 A 2D point in physical length units (not a vector — no addition)
LengthVector2 / LengthVector3 Displacement in physical length units
DoubleVector2 / DoubleVector3 Dimensionless vectors; used for normals and direction maths

Physics vectors

Type Description
SpeedVector2 / SpeedVector3 Velocity
AccelerationVector2 / AccelerationVector3 Acceleration
JerkVector2 / JerkVector3 Rate of change of acceleration
ForceVector2 / ForceVector3 Force
ImpulseVector2 / ImpulseVector3 Impulse (force × time)

Field and density vectors

Type Description
ElectricFieldVector2 / ElectricFieldVector3 Electric field
MagneticFieldVector2 / MagneticFieldVector3 Magnetic flux density
MagnetizationVector2 / MagnetizationVector3 Magnetization
ElectricCurrentDensityVector3 Electric current density (3D only)
MassFluxVector3 Mass flux (3D only)
LinearDensityVector2 Linear density
AreaVector2 Area vector
TemperatureGradientVector3 Temperature gradient (3D only)

Thunder.UnitsNET.Vectors.MonoGame

Conversion helpers between core vector types and MonoGame's Vector2 / Vector3, plus a camera type for world-to-screen projection.

Type Description
XnaVector2Extensions LengthVector2Vector2, with pixel scale (Ratio)
XnaVector3Extensions LengthVector3Vector3, with pixel scale (Ratio)
Camera2 2D world-to-screen camera using position, rotation, and pixel scale
PixelScale Pixels-per-metre scale factor
GameTimeExtensions ElapsedAsDuration(this GameTime) — bridge from MonoGame game time to UnitsNet.Duration

Thunder.UnitsNET.Vectors.Geometry

Unit-aware 2D geometry shapes, a coordinate-frame transform, and directional types. All position coordinates use LengthPoint2; all displacement vectors use LengthVector2.

Points and directions

Type Description
LengthPoint2 A 2D point in physical length units
Direction2 A normalised 2D direction (wraps an Angle); East = +X
Transform2 A 2D coordinate frame: position + rotation (Direction2) + scale (Ratio)

Linear primitives

Type Description
LengthSegment2 A finite line segment between two LengthPoint2 values
LengthRay2 A ray from an origin in a Direction2
LengthLine2 An infinite line through a point in a Direction2

Shapes

Type Description
Circle2 Circle defined by centre + Radius; FromPoints(p1, p2, p3) constructs the circumscribed circle
Rectangle2 Axis-aligned or rotated rectangle
Triangle2 Triangle with vertices A, B, C
Ellipse2 Ellipse with semi-major/minor axes and rotation
Arc2 Circular arc (partial circle); PointAt(Ratio), TangentAt(Ratio), FromPoints (circle+endpoints or 3-point with direction inference), CalculateArcPoints
Sector2 Pie-slice sector
Capsule2 Capsule (two semicircles + rectangle)
Polygon2 Arbitrary convex or concave polygon

Curves and paths

Type Description
BezierCurve2 Cubic Bézier curve; Evaluate(Ratio), TangentAt(Ratio), ToPath(resolution), EvaluateAtLength(Length), TangentAtLength(Length)
CatmullRomSpline2 Catmull-Rom spline through waypoints; same API as BezierCurve2 plus ToPath(resolution)
LengthPath2 Arc-length parameterised polyline; Evaluate(Length), TangentAt(Length), SegmentAt(Length), Project(LengthPoint2), factories FromBezier, FromCatmullRom, FromArc

Thunder.UnitsNET.Vectors.Geometry.MonoGame

MonoGame/XNA conversion helpers for geometry types, plus the full DebugDraw wireframe rendering system.

Conversions

Type Description
GeometryXnaExtensions Shape → XNA primitives (centres, radii, corners) with pixel scale
Transform2XnaExtensions Transform2Matrix for use in SpriteBatch.Begin

DebugDraw wireframe rendering

All DebugDraw methods take a SpriteBatch, a 1×1 pixel Texture2D (from DebugDrawExtensions.CreatePixelTexture), and a world-to-screen Transform2.

Type Description
DebugDrawExtensions Core helpers: CreatePixelTexture, DrawLine, WorldToScreen
PolygonDebugDrawExtensions Wireframe for Rectangle2, Triangle2, Polygon2
CurveDebugDrawExtensions Wireframe for Circle2, Ellipse2, Arc2, Sector2, Capsule2
PrimitiveDebugDrawExtensions Wireframe for LengthSegment2, LengthRay2, LengthLine2, Transform2 axes, Direction2 arrows
// One-time setup
Texture2D pixel = DebugDrawExtensions.CreatePixelTexture(GraphicsDevice);

// Per-frame, inside SpriteBatch.Begin/End
var worldToScreen = new Transform2(
    LengthPoint2.FromMeters(400, 300),   // screen centre
    Direction2.East,                      // no camera rotation
    Ratio.FromDecimalFractions(64.0));    // 64 pixels per metre

myCircle.DebugDraw(spriteBatch, pixel, worldToScreen, Color.Red);
myRect.DebugDraw(spriteBatch, pixel, worldToScreen, Color.Green);
myTransform.DebugDraw(spriteBatch, pixel, worldToScreen);
v0.7.0 ▼