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.

Structs§

Aabb
An axis-aligned bounding box (AABB)
Arc
Calculated geometry that is useful when dealing with an arc
Circle
An n-dimensional circle
Line
An n-dimensional line, defined by an origin and a direction
Plane
A plane
Point
An n-dimensional point
PolyChain
A polygonal chain
Scalar
A rational, finite scalar value
Segment
A line segment, defined by its two end points
T
1-dimensional curve coordinates
Transform
An affine transform
Triangle
A triangle
Uv
2-dimensional surface coordinates
Vector
An n-dimensional vector
Xyz
3-dimensional model coordinates

Enums§

Sign
The sign of a Scalar
Winding
Winding direction of a triangle.