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
                    
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.MonoGame" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Thunder.UnitsNET.Vectors.MonoGame" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Thunder.UnitsNET.Vectors.MonoGame" />
                    
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.MonoGame --version 0.2.0
                    
#r "nuget: Thunder.UnitsNET.Vectors.MonoGame, 0.2.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.MonoGame@0.2.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.MonoGame&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Thunder.UnitsNET.Vectors.MonoGame&version=0.2.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
0.2.0 0 4/14/2026
0.1.1 49 4/13/2026
0.1.0 46 4/13/2026