Thunder.UnitsNET.Vectors
0.4.0
See the version list below for details.
dotnet add package Thunder.UnitsNET.Vectors --version 0.4.0
NuGet\Install-Package Thunder.UnitsNET.Vectors -Version 0.4.0
<PackageReference Include="Thunder.UnitsNET.Vectors" Version="0.4.0" />
<PackageVersion Include="Thunder.UnitsNET.Vectors" Version="0.4.0" />
<PackageReference Include="Thunder.UnitsNET.Vectors" />
paket add Thunder.UnitsNET.Vectors --version 0.4.0
#r "nuget: Thunder.UnitsNET.Vectors, 0.4.0"
#:package Thunder.UnitsNET.Vectors@0.4.0
#addin nuget:?package=Thunder.UnitsNET.Vectors&version=0.4.0
#tool nuget:?package=Thunder.UnitsNET.Vectors&version=0.4.0
Thunder.UnitsNET.Vectors
A unit-aware 2D/3D vector library for physics-driven game loops. Component types come from UnitsNet, so every operation preserves physical units — LengthVector2 / Duration returns SpeedVector2, not a raw float.
Supported frameworks: net8.0, net10.0
Quick start
using Thunder.UnitsNET.Vectors;
using UnitsNet;
using UnitsNet.Units;
// Position
var position = new LengthVector2(
Length.FromMeters(3),
Length.FromMeters(4));
// Kinematics: displacement over time → velocity
SpeedVector2 velocity = position / Duration.FromSeconds(2);
// Dynamics: F = ma
var accel = new AccelerationVector2(
Acceleration.FromMetersPerSecondSquared(9.8),
Acceleration.FromMetersPerSecondSquared(0));
ForceVector2 force = accel * Mass.FromKilograms(5);
// Dot product: work = F · d (yields Energy)
Energy work = force.Dot(position);
// Normalize to a unit DoubleVector2 direction
DoubleVector2 dir = position.Normalize();
// Scalar magnitude
Length mag = position.Magnitude();
Kinematic operator chains
| Expression | Returns |
|---|---|
LengthVector2 / Duration |
SpeedVector2 |
SpeedVector2 / Duration |
AccelerationVector2 |
AccelerationVector2 / Duration |
JerkVector2 |
AccelerationVector2 * Mass |
ForceVector2 |
ForceVector2 * Duration |
ImpulseVector2 |
ForceVector2.Dot(LengthVector2) |
Energy |
ForceVector2.Dot(SpeedVector2) |
Power |
SpeedVector2.Dot(SpeedVector2) |
SpecificEnergy |
The same chains exist for all Vector3 variants.
Type inventory
2D types
| Type | Component unit | Notes |
|---|---|---|
DoubleVector2 |
double |
Dimensionless direction / normalised result |
LengthVector2 |
Length |
Position |
SpeedVector2 |
Speed |
Velocity |
AccelerationVector2 |
Acceleration |
Linear acceleration |
ForceVector2 |
Force |
Newtonian force |
JerkVector2 |
Jerk |
Rate of acceleration change |
ImpulseVector2 |
Impulse |
Momentum impulse |
MagneticFieldVector2 |
MagneticField |
|
MagnetizationVector2 |
Magnetization |
|
LinearDensityVector2 |
LinearDensity |
|
ElectricFieldVector2 |
ElectricField |
3D types
| Type | Component unit | Notes |
|---|---|---|
DoubleVector3 |
double |
Dimensionless |
LengthVector3 |
Length |
|
SpeedVector3 |
Speed |
|
AccelerationVector3 |
Acceleration |
|
ForceVector3 |
Force |
|
JerkVector3 |
Jerk |
|
ImpulseVector3 |
Impulse |
|
MagneticFieldVector3 |
MagneticField |
|
MagnetizationVector3 |
Magnetization |
|
MassFluxVector3 |
MassFlux |
|
ElectricFieldVector3 |
ElectricField |
|
ElectricCurrentDensityVector3 |
ElectricCurrentDensity |
|
TemperatureGradientVector3 |
TemperatureGradient |
Common API (all types)
| Member | Description |
|---|---|
X, Y (/ Z) |
Component accessors |
Zero |
Static zero vector |
Magnitude |
Scalar Euclidean magnitude |
Normalize() |
Returns a DoubleVector2/DoubleVector3 unit vector |
Dot(other) |
Dot product; return type depends on the pair |
As(unit) |
Returns DoubleVector2/DoubleVector3 in the specified unit |
Lerp(a, b, t) |
Unclamped linear interpolation; t outside [0,1] extrapolates |
LerpClamped(a, b, t) |
Linear interpolation with t clamped to [0, 1] |
Abs() |
Per-component absolute value |
Clamp(min, max) |
Per-component clamp to [min, max] |
ApproximatelyEquals(other, tolerance) |
Per-component tolerance check |
+, -, *, / |
Component-wise arithmetic |
==, != |
Value equality (record struct) |
ToString() |
Formatted component string |
What's new in v0.4.0
Physics integration — PhysicsIntegration in Thunder.UnitsNET.Vectors provides unit-correct Euler, Velocity Verlet, drag, and friction helpers. All methods return unit-typed results; no raw double arithmetic at call sites.
Performance — All Phase 4 hot paths benchmarked and profiled. Zero heap allocation across all manifold, raycasting, path, and physics APIs. Rectangle_Rectangle manifold: 1,466 ns → 124 ns (colliding, 11.8×) / 27 ns (non-colliding, 44×) via inline raw-double OBB-OBB SAT.
MathExtensions optimization — Squared(Length) and Sqrt(Area) are now unit-preserving and zero ToUnit() calls. Length.FromFeet(4).Squared() returns Area in SquareFoot.
See also — CHANGELOG.md for the full Phase 4 release notes (M19–M26.2).
What's new in v0.3.0
Performance — Magnitude improved from 5.1 ns to 1.93 ns; Normalize is proportionally faster. All unit vector types now embed DoubleVector2/DoubleVector3 as their backing field, delegating raw math to a single authoritative layer. A future improvement to DoubleVector2/3 propagates automatically to all 23 types.
Build hygiene — Zero compiler warnings. CS1574 promoted to WarningsAsErrors.
See also — CHANGELOG.md for the full Phase 3 release notes covering M13–M18.2 (spatial queries, camera/viewport, generator improvements, benchmark suite, and internal representation overhaul).
Packages in this family
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Thunder.UnitsNET.Vectors:
| Package | Downloads |
|---|---|
|
Thunder.UnitsNET.Vectors.MonoGame
MonoGame/XNA integration for Thunder.UnitsNET.Vectors. Converts unit-aware LengthVector2/Vector3 to XNA Vector2/Vector3 with explicit scale, keeping physics and rendering units separate. |
|
|
Thunder.UnitsNET.Vectors.Geometry
Unit-aware 2D geometry types built on Thunder.UnitsNET.Vectors. Shapes, directions, and spatial primitives for physics-driven game loops. |
|
|
Thunder.UnitsNET.Vectors.Geometry.MonoGame
MonoGame/XNA integration for Thunder.UnitsNET.Vectors.Geometry. Converts unit-aware 2D geometry shapes to XNA rendering primitives with explicit scale, keeping physics and rendering units separate. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.7.0 | 148 | 5/5/2026 |
| 0.7.0-preview37 | 141 | 5/5/2026 |
| 0.7.0-preview36 | 143 | 5/5/2026 |
| 0.7.0-preview35 | 147 | 5/4/2026 |
| 0.6.0-preview34 | 157 | 4/28/2026 |
| 0.6.0-preview33 | 141 | 4/27/2026 |
| 0.6.0-preview32 | 142 | 4/27/2026 |
| 0.5.0 | 165 | 4/23/2026 |
| 0.5.0-preview31 | 139 | 4/28/2026 |
| 0.5.0-preview30 | 176 | 4/28/2026 |
| 0.5.0-preview29 | 142 | 4/28/2026 |
| 0.5.0-preview28 | 151 | 4/28/2026 |
| 0.5.0-preview27 | 138 | 4/28/2026 |
| 0.4.0 | 163 | 4/22/2026 |
| 0.4.0-preview6 | 144 | 4/20/2026 |
| 0.4.0-preview5 | 137 | 4/20/2026 |
| 0.4.0-preview4 | 140 | 4/20/2026 |
| 0.4.0-preview25 | 135 | 4/20/2026 |
| 0.4.0-preview24 | 141 | 4/20/2026 |
| 0.4.0-preview23.1 | 61 | 4/20/2026 |