Expand description

Fornjot Math Library

This library is part of the Fornjot ecosystem. Fornjot is an open-source, code-first CAD application; and collection of libraries that make up the CAD application, but can be used independently.

This library is an internal component of Fornjot. It is not relevant to end users that just want to create CAD models.

This crates provides basic math types for the Fornjot ecosystem. It is built on nalgebra and Parry, but provides an interface that is specifically tailored to the needs of Fornjot.

Failing From/Into implementations

Please note that any From/Into implementation that convert floating point numbers into Scalar can panic. These conversions call Scalar::from_f64 internally and panic under the same conditions. This affects Scalar itself, but also any other types in this crate that provide conversions from types that involve f64.

This explicitly goes against the mandate of From/Into, whose documentation states that implementations must not fail. This is a deliberate design decision. The intended use case of Scalar is math code that considers NaN results a bug, not a recoverable error.

For this use case, having easy conversions available is an advantage, and explicit unwrap/expect calls would add nothing. In addition, the From/Into documentation fails to provide any reasons for its mandate.

Structs

An axis-aligned bounding box (AABB)

An n-dimensional circle

An n-dimensional line, defined by an origin and a direction

An n-dimensional point

A polygonal chain

A rational, finite scalar value

A line segment, defined by its two end points

1-dimensional curve coordinates

An affine transform

A triangle

2-dimensional surface coordinates

An n-dimensional vector

3-dimensional model coordinates

Enums

Winding direction of a triangle.