Thunder.UnitsNET.Vectors.MonoGame
0.2.0
dotnet add package Thunder.UnitsNET.Vectors.MonoGame --version 0.2.0
NuGet\Install-Package Thunder.UnitsNET.Vectors.MonoGame -Version 0.2.0
<PackageReference Include="Thunder.UnitsNET.Vectors.MonoGame" Version="0.2.0" />
<PackageVersion Include="Thunder.UnitsNET.Vectors.MonoGame" Version="0.2.0" />
<PackageReference Include="Thunder.UnitsNET.Vectors.MonoGame" />
paket add Thunder.UnitsNET.Vectors.MonoGame --version 0.2.0
#r "nuget: Thunder.UnitsNET.Vectors.MonoGame, 0.2.0"
#:package Thunder.UnitsNET.Vectors.MonoGame@0.2.0
#addin nuget:?package=Thunder.UnitsNET.Vectors.MonoGame&version=0.2.0
#tool nuget:?package=Thunder.UnitsNET.Vectors.MonoGame&version=0.2.0
Thunder.UnitsNET.Vectors.MonoGame
MonoGame / XNA integration for Thunder.UnitsNET.Vectors.
Provides extension methods to convert unit-aware LengthVector2/LengthVector3 (and their derived types) to and from XNA Vector2/Vector3. Scaling is explicit — you always supply the unit and pixels-per-unit factor, making camera zoom and resolution independence easy to reason about.
Quick start
// dotnet add package Thunder.UnitsNET.Vectors
// dotnet add package Thunder.UnitsNET.Vectors.MonoGame
using Thunder.UnitsNET.Vectors;
using Thunder.UnitsNET.Vectors.MonoGame;
using UnitsNet.Units;
using Microsoft.Xna.Framework;
// Physics world position (e.g. from your physics update)
var worldPos = new LengthVector2(
Length.FromMeters(1.5),
Length.FromMeters(-2.0));
// Convert to screen pixels (64 px per metre)
const double ppm = 64.0;
Vector2 screen = worldPos.ToXnaVector2(LengthUnit.Meter, ppm);
// Convert back (e.g. mouse pick ray → world coords)
LengthVector2 picked = screen.ToLengthVector2(LengthUnit.Meter, ppm);
Conversion API
2D extensions (XnaVector2Extensions)
| Method | From | To | Notes |
|---|---|---|---|
ToXnaVector2(unit, scale) |
LengthVector2 |
Vector2 |
Components converted to unit, multiplied by scale |
ToXnaVector2(unit, scale) |
DoubleVector2 |
Vector2 |
Direction-only; scale applied |
ToLengthVector2(unit, scale) |
Vector2 |
LengthVector2 |
XNA pixels divided by scale, wrapped in unit |
ToDoubleVector2() |
Vector2 |
DoubleVector2 |
Raw cast; no scaling |
3D extensions (XnaVector3Extensions)
| Method | From | To | Notes |
|---|---|---|---|
ToXnaVector3(unit, scale) |
LengthVector3 |
Vector3 |
Same semantics as 2D |
ToXnaVector3(unit, scale) |
DoubleVector3 |
Vector3 |
|
ToLengthVector3(unit, scale) |
Vector3 |
LengthVector3 |
|
ToDoubleVector3() |
Vector3 |
DoubleVector3 |
Scale-aware overloads
All ToXna* overloads accept an optional scale parameter (default 1.0). Pass your pixels-per-unit constant at the call site rather than storing it as a global, so the conversion intent is explicit in code.
MonoGame dependency note
MonoGame.Framework.DesktopGL is declared as PrivateAssets="all" in this package. You must add your own platform-specific MonoGame package to your game project (e.g. MonoGame.Framework.DesktopGL, MonoGame.Framework.WindowsDX). This package works with any MonoGame platform.
Source repository
https://code.thundersizzle.tech/Thunder/thunder-unitsnet-vectors
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Thunder.UnitsNET.Vectors (>= 0.2.0)
- UnitsNet (>= 5.67.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Thunder.UnitsNET.Vectors.MonoGame:
| Package | Downloads |
|---|---|
|
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.