Thunder.UnitsNET.Vectors 0.7.0

dotnet add package Thunder.UnitsNET.Vectors --version 0.7.0
                    
NuGet\Install-Package Thunder.UnitsNET.Vectors -Version 0.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Thunder.UnitsNET.Vectors" Version="0.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Thunder.UnitsNET.Vectors" Version="0.7.0" />
                    
Directory.Packages.props
<PackageReference Include="Thunder.UnitsNET.Vectors" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Thunder.UnitsNET.Vectors --version 0.7.0
                    
#r "nuget: Thunder.UnitsNET.Vectors, 0.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Thunder.UnitsNET.Vectors@0.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Thunder.UnitsNET.Vectors&version=0.7.0
                    
Install as a Cake Addin
#tool nuget:?package=Thunder.UnitsNET.Vectors&version=0.7.0
                    
Install as a Cake Tool

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.5.0

Unit-preserving operatorsJerk × Duration, Force × Duration, and Speed × Mass operators across all V2 and V3 types now preserve the caller's unit choice. Unit-mapping switches replace the previous SI-forced extraction pattern. Length.FromFeet(3) * Speed.FromFeetPerSecond(4) returns Momentum in FootPoundPerSecond, not KilogramMeterPerSecond.

Angular dynamicsTorqueVector3, RotationalSpeedVector3, RotationalAccelerationVector3 with cross-type operators: TorqueVector3 / MomentOfInertia → RotationalAccelerationVector3, RotationalSpeedVector3 × Duration → Angle, and scalar multiplication. All types are source-generated — zero hand-written boilerplate.

Polar constructors and dimension liftingLengthVector2.FromPolar(Radius, Angle) constructs a vector from magnitude and direction. LengthVector2.Extend(z)LengthVector3 lifts into 3D; LengthVector3.Truncate()LengthVector2 drops the Z component.

See alsoCHANGELOG.md for full Phase 5 release notes (M27–M31.2).


What's new in v0.4.0

Physics integrationPhysicsIntegration 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 optimizationSquared(Length) and Sqrt(Area) are now unit-preserving and zero ToUnit() calls. Length.FromFeet(4).Squared() returns Area in SquareFoot.

See alsoCHANGELOG.md for the full Phase 4 release notes (M19–M26.2).


What's new in v0.3.0

PerformanceMagnitude 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 alsoCHANGELOG.md for the full Phase 3 release notes covering M13–M18.2 (spatial queries, camera/viewport, generator improvements, benchmark suite, and internal representation overhaul).


📖 API docs · 💻 Source

Packages in this family

NuGet Thunder.UnitsNET.Vectors — Core vector types (this package)
NuGet Thunder.UnitsNET.Vectors.MonoGame — XNA/MonoGame conversions
NuGet Thunder.UnitsNET.Vectors.Geometry — Unit-aware 2D geometry
NuGet Thunder.UnitsNET.Vectors.Geometry.MonoGame — Geometry → MonoGame
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed