Thunder.UnitsNET.Vectors
Unit-aware 2D/3D vector types for physics-driven game loops. Component types come from UnitsNet, so every operation preserves physical units — LengthVector2 / Duration returns SpeedVector2, not a raw float.
Packages
See the API Reference for the full type inventory.
Quick start
using Thunder.UnitsNET.Vectors;
using Thunder.UnitsNET.Vectors.Geometry;
using UnitsNet;
// Position
var position = new LengthVector2(Length.FromMeters(3), Length.FromMeters(4));
// Kinematics: displacement / 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 (returns Energy)
Energy work = force.Dot(position);
// Collision manifold
var a = Rectangle2.FromCenterAndSize(LengthPoint2.Origin, Length.FromMeters(2), Length.FromMeters(2));
var b = Rectangle2.FromCenterAndSize(LengthPoint2.FromMeters(1, 0), Length.FromMeters(2), Length.FromMeters(2));
if (a.TryGetManifold(b, out var manifold))
{
// Resolve: push 'a' out by penetration depth along contact normal
}
// Physics integration
var newPos = PhysicsIntegration.Euler(position, velocity, Duration.FromSeconds(1.0 / 60));
💻 Source