Header menu logo Euclid

Logo

Euclid

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

Euclid is a 2D and 3D geometry library for F# without dependencies.
It is mostly focused on creating and manipulating primitives such as
points, vectors, lines, planes, boxes, bounding boxes, and polylines.
For transformations of those there are rotations, quaternions, 4x4 and rigid orthonormal 4x3 matrices.

Written in F# and designed for use with F#,
all primitive types are immutable and functions are curried where appropriate.

This library is intended to be used for design, construction, and manufacturing.
So it uses double-precision floating point numbers for all values. (While most geometry libraries for games use single-precision floats.)

See Euclid.Rhino for converting from and to Rhino3D geometry.

This library can be compiled to JavaScript, TypeScript, Rust, or Python via Fable.

Where does Z point to?

This library assumes a right-handed coordinate system with the Z-axis pointing up.
Just like Rhino3D, Blender, SketchUp, Revit, and AutoCAD have it. But unlike Unity, Unreal, or Maya.

Design decisions

In this library, a point is a position in space, a vector is a direction in space.
A 4x4 transformation matrix applied to a vector will only rotate and scale the vector but not translate it.
You could think of this as a homogeneous coordinate system where the last value is 0 (not 1), thus disabling translation.

A 2D point is called Pt and a 3D point is called Pnt.
A 2D vector is called Vc and a 3D vector is called Vec.

This library has dedicated types for unit vectors in 2D and 3D space.
They are called UnitVc and UnitVec respectively.
They are guaranteed to have a length of 1.0.

All types have respective modules with the same name for functions that operate on them.
Many functions exist as both a lowercase static member and an uppercase method or property.
e.g.: Vec.unitized(v) is the same as the v.Unitized property.

Full API Documentation

goswinr.github.io/Euclid

Changelog

See CHANGELOG.md

Build from source

Just run dotnet build in the root directory.

Tests

All tests run in both JavaScript and .NET. The TypeScript result is verified with the TypeScript compiler. Go to the tests folder:

or:

cd Tests

For testing with .NET using Expecto run

dotnet run

For testing with Fable.Mocha run

npm test

License

MIT

Type something to start searching.