Units and Tolerances
Units: your choice, one choice
The kernel is unit-agnostic — a number is a number. Brep.box(100, 100, 100) is a 100-unit cube whether you mean millimeters or inches. The convention only has to be consistent within a document and across booleans: mixing a millimeter part with a meter tool gives a valid, useless result.
Practical conventions used across the ecosystem:
- Model documents and in-repo callers assume millimeters.
- The glTF scene writer is the one place units convert: it maps Z-up millimeters → Y-up meters, per the glTF spec.
Orientation: Z-up
World up is +Z, everywhere: cylinder axes, extrusions, gravity. Renderers that default to Y-up (three.js) need one line — camera.up.set(0, 0, 1) — or the glTF writer's built-in conversion when exporting.
Tolerances: eps is relative
Measurement doors take an epsilon, and Brep.measurementDefaultEps() returns the kernel default: 1e-6, a relative stopping band for the volume/area quadrature — not an absolute distance.
import { Brep } from '@huukhanhnguyen/geometry'
const eps = Brep.measurementDefaultEps()
Brep.volume(part, eps) // stop refining when the remaining band < eps × magnitudePass it rather than hardcoding a number; the default tracks the kernel.
What accuracy to expect
- Planar geometry (boxes, prisms): closed-form exact. Tests assert volumes to
1e-9. - Curved geometry after booleans: the tessellator's sag shows up in measured volume. Compare with a loose band — the kernel's own parity tests use ~
1e-2relative for curved boolean volumes, not1e-9. - Tessellation deflection is a different tolerance: max surface-to-triangle distance in model units, controlled per call (
Brep.tessellate(doc, deflection)), defaulting to the face-measuredBrep.measurementDeflection(doc). - Mesh weld has its own vertex-merge tolerance, default
1e-4(TriangleMesh.weld).
Rule of thumb
Exact input → exact output. The moment a curve is approximated (tessellation, faceted import, curved booleans), pick a comparison band appropriate to the approximation, not machine epsilon.
Where next
- Guide: Tessellate for display — deflection in depth.
- Guide: Create and measure solids.