ZGeometry 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ZGeometry --version 0.2.0
                    
NuGet\Install-Package ZGeometry -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="ZGeometry" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZGeometry" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="ZGeometry" />
                    
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 ZGeometry --version 0.2.0
                    
#r "nuget: ZGeometry, 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 ZGeometry@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=ZGeometry&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=ZGeometry&version=0.2.0
                    
Install as a Cake Tool

ZGeometry

A small, generic 2D geometry library for .NET. It provides a numeric vector type and a handful of 2D primitives (circle, rectangle, triangle, line, point) with a fluent API for the common spatial queries: overlaps, contains, and intersects.

Everything is generic over the numeric type (float, double, int, long, decimal, byte) via System.Numerics.INumber<T>, so you can pick the precision you need.

⚠️ Disclaimer: This is a small hobby library. It's handy for games, prototypes, and learning, but it is not a comprehensive or heavily optimised computational-geometry package. Expect a limited primitive set and possible breaking changes between versions.

Features

  • Vector2D<T> — a generic 2D vector with arithmetic operators and helpers: Magnitude, Normalize, DotProduct, CrossProduct, Perpendicular, Lerp, Reflect, Clamp, polar/cartesian conversion, and more.
  • PrimitivesCircle<T>, Rectangle<T>, Triangle<T>, Line<T>, each with Create(...) factories.
  • Fluent spatial queriesOverlaps, Contains, and Intersects extension methods across primitive pairs.
  • Tuple sugar(T, T) implicitly converts to Vector2D<T>, so call sites stay terse.

Installation

dotnet add package ZGeometry

Getting started

Vectors

using ZGeometry.Primitives.Point;

var a = Vector2D<float>.Create(3, 4);
var b = new Vector2D<float>(1, 2);

var sum       = a + b;            // (4, 6)
var scaled    = a * 2f;           // (6, 8)
var length    = a.Magnitude();    // 5
var unit      = a.Normalize();
var dot       = a.DotProduct(b);

Primitives

Each primitive has a Create factory. The numeric type is inferred from the arguments, and (x, y) tuples convert to vectors automatically.

using ZGeometry.Primitives.Circle;
using ZGeometry.Primitives.Rectangle;
using ZGeometry.Primitives.Line;
using ZGeometry.Primitives.Triangle;

var circle    = Circle<float>.Create((100, 100), 40);
var rectangle = Rectangle<float>.Create((10, 10), (200, 120));   // position, size
var line      = Line<float>.Create((0, 0), (300, 300));
var triangle  = Triangle<float>.Create((0, 0), (100, 0), (50, 80));

Spatial queries

The fluent extension methods read naturally. Overlaps and Contains return bool; Intersects returns the boundary intersection points.

using ZGeometry.Logic;

bool touching   = circle.Overlaps(rectangle);
bool inside     = circle.Contains(line);
var  crossings  = circle.Intersects(line);   // IEnumerable<Vector2D<float>>

Namespaces at a glance

Namespace What's in it
ZGeometry.Primitives.Point Vector2D<T>
ZGeometry.Primitives.Circle Circle<T> and its Create factory
ZGeometry.Primitives.Rectangle Rectangle<T> and its Create factory
ZGeometry.Primitives.Triangle Triangle<T> and its Create factory
ZGeometry.Primitives.Line Line<T> and its Create factory
ZGeometry.Logic Overlaps, Contains, Intersects fluent queries

License

MIT

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 was computed.  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.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ZGeometry:

Package Downloads
SimpleHMEngine

A small, hobby 2D game engine built on SFML.Net: game loop, scene/component tree, input binding, camera, simple collision, an immediate-mode drawing helper, and a lightweight UI toolkit. Great for prototypes, game jams and learning — not a production engine.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.2 150 6/13/2026
0.2.1 135 6/9/2026
0.2.0 160 6/9/2026

0.2.0: Packaged README and standard NuGet metadata; published as a standalone package.