Euclid 1.0.0-alpha3
Prefix Reserveddotnet add package Euclid --version 1.0.0-alpha3
NuGet\Install-Package Euclid -Version 1.0.0-alpha3
<PackageReference Include="Euclid" Version="1.0.0-alpha3" />
<PackageVersion Include="Euclid" Version="1.0.0-alpha3" />
<PackageReference Include="Euclid" />
paket add Euclid --version 1.0.0-alpha3
#r "nuget: Euclid, 1.0.0-alpha3"
#:package Euclid@1.0.0-alpha3
#addin nuget:?package=Euclid&version=1.0.0-alpha3&prerelease
#tool nuget:?package=Euclid&version=1.0.0-alpha3&prerelease

Euclid
A comprehensive library for primitive 2D and 3D geometry in and for F#, without dependencies, designed for precision engineering and computational design.
It runs on JavaScript too.
Is this vibe coded ?
No, from 2019 till 2025 it was crafted by hand with careful attention to performance and correctness.
But of course, the powerful LLMs from 2026 caught a few real bugs, added some functionality,
wrote a lot of tests and helped unify and standardize the public API surface for release 1.0
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 also 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, Rectangles, Boxes, Bounding Boxes, Polylines
- Rotations, Quaternions, 4x4 and rigid orthonormal 4x3 matrices
✨ Key Characteristics
- Zero dependencies: lightweight and self-contained
- Double precision: designed for CAD/manufacturing accuracy
- Immutable types: geometry types are immutable for safety and ease of reasoning, except
Polyline2D,Polyline3DandFreeBox - Cross-platform: compiles to .NET, JavaScript, TypeScript and more via Fable
- Performance Focus: All small types are structs, functions are often inline and try to minimize allocations.
Extensions
- use Euclid.Rhino for Rhino3D integration.
- use Euclid.BVH for efficient spatial indexing and collision detection via a bounding-volume-hierarchy tree.
- use Euclid.Kontur for efficient boolean operations on 2d polylines.
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 = point1.DistanceTo 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.createRotationZDegrees 45
point1
|> Pnt.move 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.
A vector in Euclid is just a direction with a magnitude. It has no location in space. Therefore transformations that depend on a location never apply to vectors:
- A vector cannot be moved. Moving a direction is meaningless; it stays the same vector.
- A vector cannot be rotated around a center point. Only location-bearing types
(points, lines, planes, rectangles, boxes, polylines) can rotate around a center.
Vectors only rotate around the origin (a pure rotation, e.g.
Vec.rotate,Vec.rotateOnZ).
The API enforces this: vector types (Vc, Vec, UnitVc, UnitVec) deliberately offer no
move, rotateAround or scaleOn members.
Mutability
All types are immutable, except Polyline2D, Polyline3D and FreeBox.
These three are classes that wrap a flat Resizable array of float coordinates.
Their instance members, such as Move, Rotate, Transform, Reverse or SetPoint, change the instance in place and return unit.
Their static functions, such as Polyline2D.move or Polyline2D.reverse, return a new instance and leave the input unchanged.
Only the indexed point setters and movers, like setPoint and movePoint, and the append functions, like addPoint, mutate as static functions too.
XYs and XYZs give access to the live coordinate buffer.
Call Duplicate() to get an independent copy before you change a shared instance.
Rays
A ray in Euclid is a line extended infinitely in both directions.
Functions with Ray in their name, such as XLine2D.classifyRayIntersection, Line3D.RayClosestParameters
or BBox.IntersectRay, take a finite Line2D or Line3D and treat it as infinite.
Their parameters are measured along that line: 0.0 is at its From point and 1.0 at its To point.
Values below 0.0 or above 1.0 are valid results.
Functions that intersect two rays say Rays, like Line2D.intersectRays and XLine3D.tryIntersectRays.
Naming Conventions
Core Types (2D and 3D):
| Type | 2D | 3D |
|---|---|---|
| Point | Pt |
Pnt |
| Vector | Vc |
Vec |
| Unit Vector | UnitVc |
UnitVec |
| Line | Line2D |
Line3D |
| Polyline | Polyline2D |
Polyline3D |
| Rectangle | Rect2D |
Rect3D |
| Bounding Rectangle/Box | BRect |
BBox |
Member names follow the same split:
2D members that take or return points or vectors usually say Pt or Vc in their name,
and their 3D counterparts say Pnt or Vec.
For example BRect.MinPt and BBox.MinPnt, Tria2D.offsetPt and Tria3D.offsetPnt,
or Line2D.isParallelToVc and Line3D.isParallelToVec.
3D-only Types:
| Type | Description |
|---|---|
PPlane |
Parametrized plane (origin + X/Y/Z axes) |
NPlane |
Normal plane (origin + normal vector) |
Box |
Oriented 3D box (origin + 3 axis vectors) |
FreeBox |
Mutable box-like topology with 8 freely placed corner points |
Matrix |
4x4 transformation matrix |
RigidMatrix |
4x3 rigid transformation (rotation + translation only) |
Quaternion |
Unitized quaternion for 3D rotations |
Rotation2D |
2D rotation stored as sine/cosine pair |
Function Patterns
Functions are available in multiple forms:
// Static module function (lowercase, pipeable)
let normalized = Vec.unitize myVector
let moved = Pnt.move myVec myPoint
// Instance method/property (uppercase)
let normalized = myVector.Unitized
let moved = myPoint.Transform myMatrix
// Pipeline style
myPoint
|> Pnt.move (Vec(1, 0, 0))
|> Pnt.rotateOnZDegrees 45.0
|> Pnt.transform myMatrix
Static functions with several arguments are curried, so they work with |> and partial application.
Configuration comes first and the geometry last: Rect3D.createFromPlane sizeX sizeY plane, Points3D.closestPoint pt points.
Natural orders stay: Vec.create x y z, Pnt.lerp start finish factor.
These stay tupled because their argument order is easy to mix up:
functions with more than three arguments of the same type (like Quaternion.create or FreeBox.createFrom4Pts),
create...Unchecked factories, cross and the matrix and quaternion multiply.
If the last argument, the geometry, has another type, the function may still be curried, like Box.offset distBottom distFront distRight distBack distLeft distTop box.
Static constant values are PascalCase, unlike static functions: Vec.XAxis, UnitVec.ZAxis, Pnt.Origin, PPlane.WorldXY, NPlane.WorldXY, Quaternion.Identity.
A function with optional settings comes in two forms. The plain name is curried and uses the defaults.
The name ending in Custom is tupled and takes the settings as optional named arguments:
let p = XLine2D.tryIntersectRays lineA lineB
let q = XLine2D.tryIntersectRaysCustom(lineA, lineB, tangent = Tangent.``1.0``)
let pl = Polyline2D.offsetCustom(myPolyline, 2.0, loop = true)
Rotating and Scaling
Rotations and scaling share one curried naming grammar, with the geometry as the last argument:
| Function | Meaning |
|---|---|
rotate rotation geometry |
Rotate around the origin by a Rotation2D (2D) or a Quaternion (3D) |
rotateDegrees degrees geometry |
Rotate around the origin by an angle in degrees (2D) |
rotateRadians radians geometry |
Rotate around the origin by an angle in radians (2D) |
rotateAround center rotation geometry |
Rotate around a center point |
rotateDegreesAround center degrees geometry |
Rotate around a center point by an angle in degrees (2D) |
rotateRadiansAround center radians geometry |
Rotate around a center point by an angle in radians (2D) |
scale factor geometry |
Scale from the origin |
scaleOn center factor geometry |
Scale from a center point |
A raw angle argument always names its unit. The name parts of the arguments come in reverse argument order, so the last argument is named first,
as in rotateDegreesAround center degrees geometry and Matrix.createRotationFromDegreesVecAround center axis degrees. The instance members use the same names in PascalCase, e.g. ln.RotateAround cen r.
For repeated rotations, precompute the Rotation2D once and use rotate or rotateAround.
Failure and Tolerance Contracts
The name of a function tells what it does when there is no result or when its input is degenerate:
| Form | Contract | Example |
|---|---|---|
operation |
Returns the result. Raises an EuclidException if its preconditions fail |
PPlane.intersectLine, Vec.unitize |
tryOperation |
Returns a voption. ValueNone if an ordinary geometric result is absent |
PPlane.tryIntersectLine, Vec.tryUnitize |
classify… |
Returns a discriminated union that describes the relationship | XLine2D.classifyIntersection |
operationOrDefault |
Returns the given fallback instead of failing | Vec.unitizeOrDefault |
operationUnchecked |
Skips the documented checks | Vec.unitizeUnchecked, UnitVec.createUnchecked |
Intersections of two rays come in both forms, intersectRays and tryIntersectRays.
Intersections of two finite lines only have the try and classify forms, like Line2D.tryIntersect and XLine2D.classifyIntersection,
because two segments that do not reach each other are an ordinary result.
Equality follows the same idea: equalsExact a b compares each coordinate with =,
and equalsWithin tol a b allows each coordinate to differ by up to tol.
The tolerance applies to each coordinate separately, not to the Euclidean distance.
So two 3D points that differ by tol in X, Y and Z are equal, although they are sqrt 3.0 * tol apart.
To compare by distance, use Pnt.distanceTo a b <= tol or Pnt.distanceToSq a b <= tol * tol.
Custom Operators
a + b // Point + Vector = Point, Vector + Vector = Vector
a - b // Point - Point = Vector, Point - Vector = Point
a * 2.0 // Scale vector or point
a / 2.0 // Divide (with zero-check)
a *** b // Dot product for vectors, matrix multiplication for matrices
-a // Negate a vector
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.
The CHECKED_EUCLID compiler flag
Several hot paths contain extra validation that is only compiled in when the DEBUG or the
CHECKED_EUCLID symbol is defined, for example:
NaNandInfinitychecks in thePt,Pnt,VcandVecconstructors- verifying that
UnitVcandUnitVecreally have length 1.0 - range checks in
Rotation2D.createFromSineandcreateFromCosine - index bounds checks in
Polyline2DandPolyline3D - validation in every unsafe
createUncheckedconstructor: perpendicular and right-handed axes inRect2D,Rect3D,BoxandPPlane, a unitized normal inNPlane, a unitizedQuaternion, and min values not bigger than max values inBRectandBBox
These checks are off by default in release builds because they can be expensive. Some primitive operations are up to 2.5 times slower with them enabled.
CHECKED_EUCLID exists so that the checks can be turned on independently of DEBUG.
This is mostly useful with Fable: Fable compiles the referenced libraries from source
rather than consuming a pre-built assembly, so the symbol actually reaches Euclid's code
and the checks end up in the generated JavaScript or TypeScript, even in a release build.
Enable it in the consuming project file:
<PropertyGroup>
<DefineConstants>$(DefineConstants);CHECKED_EUCLID</DefineConstants>
</PropertyGroup>
or on the command line:
dotnet fable --define CHECKED_EUCLID
On .NET the flag only has an effect when Euclid is built from source. The Euclid package on NuGet is pre-compiled without it.
Development
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 Scriptorium)
Building from Source
git clone https://github.com/goswinr/Euclid.git
cd Euclid
To build the library and the tests for .NET
dotnet build --configuration Release
for JavaScript/TypeScript (compiles the .NET code to JavaScript via Fable)
cd Test
npm i
npm run build
cd ..
Testing
Tests run on both .NET and JavaScript with TypeScript build verification.
.NET Testing
run the tests from root. (not from within the Test folder)
dotnet run --project ./Test/Test.fsproj
JavaScript Testing
run
cd Test
npm i
npm test
cd ..
The test suite ensures cross-platform compatibility and verifies TypeScript type definitions.
Benchmarks
Some more complex algorithms are benchmarked in both .NET and Node JavaScript. See Test/Benchmarks/README.md.
Contributing
Contributions are welcome!
Changelog
See CHANGELOG.md for version history.
License
Examples
Points and Vectors (2D)
open Euclid
// 2D points and vectors
let a = Pt(1.0, 2.0)
let b = Pt(4.0, 6.0)
// Distance between points
let dist = a.DistanceTo b // 5.0
// Midpoint
let mid = Pt.midPt a b // Pt(2.5, 4.0)
// 2D vectors
let v = Vc(3.0, 4.0)
let len = v.Length // 5.0
let half = v.Half // Vc(1.5, 2.0)
let perp = v.Rotate90CCW // perpendicular vector
// Point + vector arithmetic
let moved = a + v // Pt(4.0, 6.0)
let diff = b - a // Vc(3.0, 4.0) : point - point = vector
// Unit vectors (guaranteed length 1.0)
let dir = v.Unitized // UnitVc(0.6, 0.8)
let angle = v.Direction360 // angle in degrees from X-axis
// Dot and cross product
let dot = v.Dot(Vc(1.0, 0.0)) // 3.0
let cross = v.Cross(Vc(1.0, 0.0)) // -4.0 (signed area in 2D)
Points and Vectors (3D)
open Euclid
// 3D points and vectors
let p1 = Pnt(1.0, 2.0, 3.0)
let p2 = Pnt(4.0, 6.0, 3.0)
// Distance, midpoint, lerp
let dist = p1.DistanceTo p2 // 5.0
let mid = Pnt.midPnt p1 p2 // Pnt(2.5, 4.0, 3.0)
let lerp = Pnt.lerp p1 p2 0.25 // 25% from p1 towards p2
// 3D vectors
let v1 = Vec(1.0, 0.0, 0.0)
let v2 = Vec(0.0, 1.0, 0.0)
// Cross product and dot product
let normal = v1.Cross v2 // Vec(0, 0, 1)
let dot = v1.Dot v2 // 0.0
// Angle between vectors
let angle = Vec.angle180 v1 v2 // 90.0 degrees
// Unit vectors
let dir = Vec(3.0, 4.0, 0.0).Unitized // UnitVec(0.6, 0.8, 0.0)
let isPerp = dir.IsPerpendicularTo UnitVec.ZAxis // true
// Convert between 2D and 3D
let pt2d = p1.AsPt // Pt(1.0, 2.0) - drops Z
let pt3d = Pt(1.0, 2.0).WithZ 5.0 // Pnt(1.0, 2.0, 5.0)
Lines
open Euclid
// Create lines from points
let ln2d = Line2D(Pt(0, 0), Pt(10, 0))
let ln3d = Line3D(Pnt(0, 0, 0), Pnt(10, 5, 3))
// Or from coordinates
let ln = Line2D(0.0, 0.0, 10.0, 5.0)
// Line properties
let len = ln2d.Length // 10.0
let midPt = ln2d.Mid // Pt(5, 0)
let vec = ln3d.Vector // Vec from start to end, with the length of the line
let dir = ln3d.UnitTangent // UnitVec of the line direction
// Evaluate at parameter (0.0 = start, 1.0 = end)
let quarterPt = ln2d.EvaluateAt 0.25 // Pt(2.5, 0)
// Extend, shrink, reverse
let longer = ln2d.Extend(2.0, 3.0) // extend 2 at start, 3 at end
let shorter = ln2d.Shrink(1.0, 1.0) // shrink 1 from each end
let flipped = ln2d.Reversed // swap start and end
// Closest point queries
let testPt = Pt(5.0, 3.0)
let closest = ln2d.ClosestPoint testPt // Pt(5, 0) - clamped to segment
let param = ln2d.ClosestParameter testPt // 0.5
// Line-line relationships
let other = Line2D(Pt(5, -5), Pt(5, 5))
let isParallel = ln2d.IsParallelTo other // false
let isPerp = ln2d.IsPerpendicularTo other // true
// Intersection of the two finite lines (returns a voption)
let hit = Line2D.tryIntersect ln2d other // ValueSome (Pt(5, 0))
// Intersection of the two lines extended infinitely
let hitRays = Line2D.tryIntersectRays ln2d other // ValueSome (Pt(5, 0))
let ptRays = Line2D.intersectRays ln2d other // Pt(5, 0), fails if the rays are parallel
// Offset a line
let offsetLn = Line2D.offset 2.0 ln2d // offset by 2.0 to the left
// Move a line
let movedLn = ln2d.Move(Vc(0.0, 5.0)) // move by a vector
Line Intersections (Discriminated Unions)
For detailed intersection analysis, the XLine2D and XLine3D modules return discriminated union types
that let you handle every case explicitly:
open Euclid
let lineA = Line2D(Pt(0, 0), Pt(10, 0))
let lineB = Line2D(Pt(5, -5), Pt(5, 5))
// Finite segment intersection - returns XPt discriminated union
match XLine2D.classifyIntersection lineA lineB with
| XLine2D.XPt.Intersect pt -> printfn $"Lines cross at {pt}"
| XLine2D.XPt.Apart -> printfn "Segments don't reach each other"
| XLine2D.XPt.Parallel -> printfn "Lines are parallel"
| XLine2D.XPt.TooShortA -> printfn "Line A is too short"
| XLine2D.XPt.TooShortB -> printfn "Line B is too short"
| XLine2D.XPt.TooShortBoth -> printfn "Both lines are too short"
// Ray intersection (rays are lines extended infinitely in both directions)
match XLine2D.classifyRayIntersection lineA lineB with
| XLine2D.XRay.Intersect pt -> printfn $"Rays meet at {pt}"
| XLine2D.XRay.Parallel -> printfn "Rays are parallel"
| _ -> ()
// 3D line relationships include skew detection
let ln3A = Line3D(Pnt(0, 0, 0), Pnt(10, 0, 0))
let ln3B = Line3D(Pnt(5, 0, 5), Pnt(5, 10, 5))
match XLine3D.classifyIntersection ln3A ln3B with
| XLine3D.XPnt.Intersect pt -> printfn $"Lines intersect at {pt}"
| XLine3D.XPnt.Skew (ptA, ptB, d) -> printfn $"Closest approach: {d} between {ptA} and {ptB}"
| XLine3D.XPnt.Apart -> printfn "Segments don't reach each other"
| XLine3D.XPnt.Parallel -> printfn "Lines are parallel"
| _ -> ()
Planes
open Euclid
// Normal plane (origin + normal direction)
let npl = NPlane(Pnt(0, 0, 5), UnitVec.ZAxis)
// Distance from plane, and signed distance (positive = same side as normal)
let d = npl.DistanceToPnt (Pnt(3, 4, 2)) // 3.0
let d2 = npl.DistanceToPntSigned (Pnt(3, 4, 2)) // -3.0
// Project a point onto the plane
let proj = npl.ClosestPoint (Pnt(3, 4, 8)) // Pnt(3, 4, 5)
// Angle between plane and vector (0 = parallel, 90 = perpendicular)
let ang = npl.Angle90ToVec (Vec(1, 0, 0)) // 0.0 (vector lies in plane)
// Parametrized plane (full coordinate frame with X, Y, Z axes)
let ppl = PPlane.createFrom3Pnts
(Pnt(0, 0, 0)) // origin
(Pnt(10, 0, 0)) // point on X-axis
(Pnt(0, 10, 0)) // point on Y-axis side
Rectangles
open Euclid
// 2D rectangle from origin, X-direction vector, and Y-size
let rect = Rect2D.createFromVc 5.0 (Vc(10, 0)) (Pt(0, 0))
// From direction and sizes
let dir = UnitVc.rotateDegrees 45.0 UnitVc.XAxis
let rotRect = Rect2D.createFromUnitVc 10.0 5.0 dir (Pt(0, 0))
// Rectangle properties
let area = rect.Area
let cx = rect.SizeX
let cy = rect.SizeY
let center = rect.Center
let c0 = rect.Origin // origin corner
let c2 = rect.FarCorner // diagonally opposite corner
// Point evaluation (u, v parameters from 0 to 1)
let midPoint = rect.EvaluateAt(0.5, 0.5) // center point
Bounding Boxes
open Euclid
// 3D axis-aligned bounding box from points
let points = [Pnt(0, 0, 0); Pnt(10, 5, 3); Pnt(-2, 8, 1)]
let bbox = BBox.createFromSeq points
// BBox properties
let size = bbox.SizeX, bbox.SizeY, bbox.SizeZ // 12.0, 8.0, 3.0
let minPt = bbox.MinPnt // Pnt(-2, 0, 0)
let maxPt = bbox.MaxPnt // Pnt(10, 8, 3)
let center = bbox.Center // Pnt(4, 4, 1.5)
let vol = bbox.Volume // 288.0
// Create from center and sizes
let box2 = BBox.createCentered 10.0 10.0 10.0 (Pnt(0, 0, 0))
// Expand bounding box
let bigger = bbox.Expand 1.0 // expand by 1.0 on all sides
// Check containment
let inside = bbox.ContainsPnt(Pnt(5, 4, 2)) // true
// Union of two bounding boxes
let combined = bbox.Union box2
Polylines
open Euclid
// Create a 2D polyline
let pl2d = Polyline2D.createFromPts [Pt(0, 0); Pt(10, 0); Pt(10, 5); Pt(0, 5)]
// Polyline properties
let len = pl2d.Length // total length
let count = pl2d.PointCount // 4
let segs = pl2d.SegmentCount // 3
// Access segments as Line2D
let firstSeg = pl2d.FirstSegment // Line2D(Pt(0,0), Pt(10,0))
let seg = pl2d.GetSegment(1) // Line2D(Pt(10,0), Pt(10,5))
// Modify (polylines are mutable)
pl2d.SetPoint (2, Pt(12, 5)) // move a vertex
let copy = pl2d.Duplicate() // deep copy
copy.Move(Vc(0, 3)) // instance members change the polyline in place
let movedPl = Polyline2D.move (Vc(0, 3)) pl2d // static functions return a new polyline
// 3D polyline
let pl3d = Polyline3D.createFromPnts [Pnt(0,0,0); Pnt(10,0,0); Pnt(10,5,3)]
let totalLen = pl3d.Length
Transformations with Matrices
open Euclid
let pt = Pnt(5.0, 0.0, 0.0)
// Translation
let m1 = Matrix.createTranslationXYZ 10.0 0.0 0.0
// Rotation (angle in degrees)
let m2 = Matrix.createRotationZDegrees 90.0 // 90 degrees around Z
let m3 = Matrix.createRotationXDegrees 45.0 // 45 degrees around X
// Rotation around arbitrary axis
let m4 = Matrix.createRotationFromDegreesUnitVec UnitVec.ZAxis 30.0
// Rotation around axis at a specific center point
let m5 = Matrix.createRotationFromDegreesVecAround (Pnt(5, 5, 0)) (Vec(0, 0, 1)) 45.0
// Scale
let m6 = Matrix.createScale 2.0 2.0 1.0 // scale X and Y by 2
// Shear
let m7 = Matrix.createShear(0.5, 0, 0, 0, 0, 0) // shear XY by 0.5
// Combine transformations: first m1, then m2, then m6
let combined = m1.Then(m2).Then(m6) // same as m1 *** m2 *** m6
// Apply to points and vectors
let pt2 = pt.Transform combined // full transform (rotate, scale, move)
let v = Vec(1, 0, 0)
let v2 = v.Transform combined // rotate and scale, the translation is ignored
let rigid = RigidMatrix.createRotationZDegrees 90.0
let v3 = v.TransformRigid rigid // rotate without translation
// Functional pipeline style
let result =
pt
|> Pnt.move (Vec(10, 0, 0))
|> Pnt.rotateOnZDegrees 90.0
|> Pnt.scale 2.0
|> Pnt.transform combined
// Matrix from plane to plane
let fromPlane = PPlane.createFrom3Pnts (Pnt(0,0,0)) (Pnt(1,0,0)) (Pnt(0,1,0))
let toPlane = PPlane.createFrom3Pnts (Pnt(5,5,0)) (Pnt(6,5,0)) (Pnt(5,6,0))
let planeXform = Matrix.createPlaneToPlane fromPlane toPlane
// Mirror about a plane
let mirror = Matrix.createMirror fromPlane
Quaternion Rotations
open Euclid
// Create quaternion from axis and angle
let q1 = Quaternion.createFromDegreesVec (Vec(0, 0, 1)) 90.0 // 90 degrees around Z
let q2 = Quaternion.createFromRadiansUnitVec UnitVec.XAxis 1.5708 // Pi/2 around X
// Rotate from one direction to another
let q3 = Quaternion.createFromUnitVecs UnitVec.XAxis UnitVec.YAxis // X -> Y
// Quaternion properties
let angle = q1.AngleInDegrees // 90.0
let axis = q1.Axis // Vec close to (0, 0, 1)
let inv = q1.Inverse // reverse rotation
// Compose rotations: first q1, then q2
let q4 = q1.Then q2
let q5 = q1 |> Quaternion.andThen q2 // same as q1.Then q2
let q6 = q1 *** q2 // Hamilton product: first q2, then q1
// Apply to points and vectors
let rotated = Pnt.rotate q1 (Pnt(1, 0, 0)) // Pnt(0, 1, 0)
// Convert quaternion to matrix
let mat = Matrix.createFromQuaternion q1
Point Cloud Operations
open Euclid
let cloud = ResizeArray [Pnt(0,0,0); Pnt(1,0,0); Pnt(5,5,5); Pnt(10,10,10)]
// Find closest point to a test point
let nearest = Points3D.closestPoint (Pnt(1.1, 0.1, 0.0)) cloud // Pnt(1,0,0)
let idx = Points3D.closestPointIndex (Pnt(1.1, 0.1, 0.0)) cloud // 1
// Closest points between two sets
let setA = ResizeArray [Pnt(0,0,0); Pnt(10,10,10)]
let setB = ResizeArray [Pnt(1,0,0); Pnt(20,20,20)]
let (iA, iB) = Points3D.closestPointsIndices setA setB // (0, 0)
// Most distant point
let farthest = Points3D.mostDistantPoint setB cloud
// center of points
let center = Points3D.center cloud // Pnt(4, 3.75, 3.75)
Error Handling
Euclid uses descriptive custom exceptions instead of silent failures:
open Euclid
// Unitizing a zero vector raises EuclidException
try
let bad = Vec(0, 0, 0).Unitized // fails: can't unitize zero vector
with e ->
printfn $"Caught: {e.Message}"
// Division by near-zero raises EuclidDivByZeroException
// NaN or Infinity in inputs raises EuclidException
// Tolerances are conservative for precision engineering:
// - zeroLengthTolerance = 1e-12 (for divisions, unitizing)
// - isTooSmall = 1e-6 (general smallness check)
| Product | Versions 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. |
-
.NETFramework 4.7.2
- FSharp.Core (>= 6.0.7)
- System.Text.Json (>= 4.6.0)
-
net6.0
- FSharp.Core (>= 6.0.7)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Euclid:
| Package | Downloads |
|---|---|
|
Euclid.Rhino
Utilities to use types from Euclid in Rhino3d |
|
|
Euclid.BVH
A Bounding Volume Hierarchy (BVH) for fast spatial queries on the Euclid geometry library. Find closest lines and pairs of close lines among thousands of 3D lines. |
|
|
Euclid.Kontur
Boolean operations on Euclid 2D polygons: union, intersection, difference, xor, simplification and union of many shapes. Floating-point coordinates with an absolute tolerance, for .NET and Fable. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha3 | 102 | 11/15/2026 |
| 0.52.0 | 459 | 10/10/2026 |
| 0.51.0 | 583 | 7/28/2026 |
| 0.50.0 | 191 | 7/16/2026 |
| 0.42.0 | 469 | 6/20/2026 |
| 0.41.0 | 228 | 6/17/2026 |
| 0.40.0 | 204 | 6/13/2026 |
| 0.30.1 | 194 | 5/23/2026 |
| 0.30.0 | 177 | 5/23/2026 |
| 0.20.0 | 534 | 2/8/2026 |
| 0.20.0-beta3 | 184 | 1/24/2026 |
| 0.20.0-beta2 | 579 | 1/23/2026 |
| 0.20.0-beta1 | 156 | 1/17/2026 |
| 0.16.0 | 729 | 6/30/2025 |
| 0.15.0 | 351 | 6/14/2025 |
| 0.14.0 | 727 | 5/24/2025 |
| 0.13.0 | 390 | 3/15/2025 |
| 0.12.0 | 571 | 11/27/2024 |
| 0.11.1 | 607 | 10/1/2024 |
| 0.11.0 | 249 | 9/25/2024 |
The changes of this release are too long for nuget.org. See https://github.com/goswinr/Euclid/blob/main/CHANGELOG.md