fj_math/lib.rs
1//! # Fornjot Math Library
2//!
3//! [Fornjot] is an early-stage b-rep CAD kernel written in Rust. The kernel is
4//! split into multiple libraries that can be used semi-independently, and this
5//! is one of those.
6//!
7//! This library provides basic math types for Fornjot. It is built on
8//! [nalgebra] and [Parry], but provides an interface that is specifically
9//! tailored to the needs of Fornjot.
10//!
11//!
12//! ## Failing [`From`]/[`Into`] implementations
13//!
14//! Please note that any [`From`]/[`Into`] implementation that convert floating
15//! point numbers into [`Scalar`] can panic. These conversions call
16//! [`Scalar::from_f64`] internally and panic under the same conditions. This
17//! affects [`Scalar`] itself, but also any other types in this crate that
18//! provide conversions from types that involve `f64`.
19//!
20//! This explicitly goes against the mandate of [`From`]/[`Into`], whose
21//! documentation states that implementations must not fail. This is a
22//! deliberate design decision. The intended use case of `Scalar` is math code
23//! that considers NaN results a bug, not a recoverable error.
24//!
25//! For this use case, having easy conversions available is an advantage, and
26//! explicit `unwrap`/`expect` calls would add nothing. In addition, the
27//! [`From`]/[`Into`] documentation fails to provide any reasons for its
28//! mandate.
29//!
30//! [Fornjot]: https://www.fornjot.app/
31//! [nalgebra]: https://nalgebra.org/
32//! [Parry]: https://www.parry.rs/
33
34mod aabb;
35mod arc;
36mod circle;
37mod coordinates;
38mod line;
39mod plane;
40mod point;
41mod poly_chain;
42mod scalar;
43mod segment;
44mod transform;
45mod triangle;
46mod vector;
47
48pub use self::{
49 aabb::Aabb,
50 arc::Arc,
51 circle::Circle,
52 coordinates::{Uv, Xyz, T},
53 line::Line,
54 plane::Plane,
55 point::Point,
56 poly_chain::PolyChain,
57 scalar::{Scalar, Sign},
58 segment::Segment,
59 transform::Transform,
60 triangle::{Triangle, Winding},
61 vector::Vector,
62};