Crate fj_math

source ·
Expand description

§Fornjot Math Library

Fornjot is an early-stage b-rep CAD kernel written in Rust. The kernel is split into multiple libraries that can be used semi-independently, and this is one of those.

This library provides basic math types for Fornjot. 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.


  • An axis-aligned bounding box (AABB)
  • Calculated geometry that is useful when dealing with an arc
  • An n-dimensional circle
  • An n-dimensional line, defined by an origin and a direction
  • A plane
  • 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