Euclid 0.20.0-beta2

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

Logo

Euclid

Euclid on nuget.org Build Status Docs Build Status Test Status license code size

A comprehensive 2D and 3D geometry library in F# without dependencies, designed for precision engineering and computational design.
It runs on JavaScript too.

Features

While most 3D geometry libraries just use a generic type ( often called Vec3 or similar) containing three floats for both points and vectors,
Euclid makes a distinction to preserve semantic meaning and avoid accidental misuse.
A point represents a position in space, while a vector represents a direction and magnitude.
Even unitized vectors are a separate type. They are guaranteed to have a length of 1.0.
This helps to skip checks for zero length vectors in many operations.

🎯 Core Geometry Types

  • Points (Pt, Pnt), Vectors (Vc, Vec), Unit Vectors (UnitVc, UnitVec)
  • Lines, Planes, Boxes, Bounding Boxes, Polylines
  • Rotations, Quaternions, 4x4 and rigid orthonormal 4x3 matrices

Key Advantages

  • Zero dependencies - lightweight and self-contained
  • Double precision - engineered for CAD/manufacturing accuracy
  • Immutable types - functional programming friendly
  • Cross-platform - compiles to .NET, JavaScript, TypeScript, Rust, Python via Fable
  • Performant - All small types are structs, functions are often inline and try to minimize the allocation of intermediate objects.

🔧 Design & Manufacturing Focus

  • Optimized for design, construction, and manufacturing workflows
  • Integrates seamlessly with Rhino3D
  • Right-handed coordinate system (Z-up) matching industry standards

Installation

Add Euclid to your F# project via NuGet:

dotnet add package Euclid

Or in F# scripting:

#r "nuget: Euclid"

Quick Start

open Euclid

// Create 3D points and vectors
let point1 = Pnt(1.0, 2.0, 3.0)
let point2 = Pnt(4.0, 5.0, 6.0)
let vector = Vec(1.0, 1.0, 0.0)

// Calculate distance
let distance = Pnt.distance point1 point2

// Create and use unit vectors
let unitVec = vector.Unitized  // returns a UnitVec

// Transform with 4x4 matrix
let matrix =
    Matrix.createShear(3.0, 0, 0, 0, 0, 0)
    *** // Combine transformations
    Matrix.createRotationZ 45

point1
|> Pnt.translate vector
|> Pnt.scale 3.0
|> Pnt.transform matrix

Coordinate System

This library uses a right-handed coordinate system with the Z-axis pointing up.

Same as in: Rhino3D, Blender, SketchUp, Revit, AutoCAD ❌ Different from: Unity, Unreal Engine, Maya

This choice aligns with industry-standard CAD and architectural software.

Design Philosophy

Points vs Vectors

  • Points (Pt, Pnt): Positions in space
  • Vectors (Vc, Vec): Directions and displacements

When a 4x4 transformation matrix is applied:

  • Points: Undergo full transformation (rotation, scaling, translation)
  • Vectors: Only rotate and scale (no translation)

This follows homogeneous coordinate conventions where vectors have w=0.

Naming Conventions

Type 2D 3D
Point Pt Pnt
Vector Vc Vec
Unit Vector UnitVc UnitVec

Function Patterns

Functions are available in multiple forms:

// Static module function (lowercase)
let normalized = Vec.unitized myVector

// Instance method/property (uppercase)
let normalized = myVector.Unitized

API Documentation

Full API Reference: goswinr.github.io/Euclid

Platform Support

Thanks to Fable, Euclid can be used not only on .NET but also in JavaScript, TypeScript, Rust, and Python.

Development

Use of AI and LLMs

All core function are are written by hand to ensure performance and correctness.
However, AI tools have been used for code review, typo and grammar checking in documentation
and to generate not all but many of the tests.

Prerequisites

  • .NET SDK 10.0 or later (to have scoped warnings available)
  • Node.js (only needed to run the .NET tests in JavaScript and TypeScript via Fable.Mocha)

Building from Source

git clone https://github.com/goswinr/Euclid.git
cd Euclid
dotnet build

Testing

Tests run on both .NET and JavaScript with TypeScript build verification.

.NET Testing

dotnet run --project ./Tests/Euclid.Tests.fsproj

JavaScript Testing

setup dependencies:

npm ci --prefix ./Tests
dotnet tool restore

then run tests:

npm run test --prefix ./Tests

The test suite ensures cross-platform compatibility and verifies TypeScript type definitions.

Contributing

Contributions are welcome!

Changelog

See CHANGELOG.md for version history.

Euclid.Rhino - Rhino3D integration

License

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Framework net472 is compatible.  net48 was computed.  net481 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 Euclid:

Package Downloads
Euclid.Rhino

Utilities to use types from Euclid in Rhino3d

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.20.0 288 2/8/2026
0.20.0-beta3 129 1/24/2026
0.20.0-beta2 360 1/23/2026
0.20.0-beta1 100 1/17/2026
0.16.0 683 6/30/2025
0.15.0 291 6/14/2025
0.14.0 686 5/24/2025
0.13.0 344 3/15/2025
0.12.0 523 11/27/2024
0.11.1 555 10/1/2024
0.11.0 208 9/25/2024
0.10.0 213 9/19/2024
0.9.0 739 7/6/2024
0.8.0 437 5/2/2024
0.7.0 210 4/29/2024
0.6.1 287 2/17/2024
0.6.1-a 184 2/13/2024
Loading failed

### Added

* - Tests for deprecated functions and modules to ensure they still work
* - Add more Tests

### Changed

* - Deprecate Loop module,
* - Make sure all renamed modules and functions have proper deprecation messages