symtropy_math/lib.rs
1// Copyright (C) 2024-2026 Tristan Stoltz / Luminous Dynamics
2// SPDX-License-Identifier: AGPL-3.0-or-later
3// Commercial licensing: see COMMERCIAL_LICENSE.md at repository root
4//! N-dimensional geometric algebra for the Symtropy consciousness-physics engine.
5//!
6//! All types are parameterized by `const D: usize` — the spatial dimension.
7//! This forces stack allocation via `nalgebra::SVector<f64, D>`, giving zero-allocation
8//! physics ticks with full SIMD optimization for the common 2D/3D/4D cases.
9//!
10//! # Usage
11//! ```
12//! use symtropy_math::{Point, Bivector, Rotor, Transform};
13//!
14//! // 3D rotation in the xy plane by 90°
15//! let plane = Bivector::<3>::unit_plane(0, 1);
16//! let r = Rotor::from_plane_angle(&plane, std::f64::consts::FRAC_PI_2);
17//! let p = Point::<3>::new([1.0, 0.0, 0.0]);
18//! let rotated = r.rotate_point(&p);
19//! ```
20//!
21//! The bivector component count is computed at compile time:
22//! - 2D: 1 component (xy)
23//! - 3D: 3 components (xy, xz, yz)
24//! - 4D: 6 components (xy, xz, xw, yz, yw, zw)
25
26pub mod bivector;
27pub mod capsule;
28pub mod convex_hull;
29pub mod halfspace;
30pub mod hyperbox;
31pub mod hyperplane;
32pub mod point;
33pub mod rotor;
34pub mod shape;
35pub mod sphere;
36pub mod transform;
37
38pub use bivector::Bivector;
39pub use capsule::Capsule;
40pub use convex_hull::ConvexHull;
41pub use halfspace::HalfSpace;
42pub use hyperbox::HyperBox;
43pub use hyperplane::Hyperplane;
44pub use point::Point;
45pub use rotor::Rotor;
46pub use shape::Shape;
47pub use sphere::Sphere;
48pub use transform::Transform;
49
50/// Type alias for common dimension specializations.
51pub type Point2 = Point<2>;
52pub type Point3 = Point<3>;
53pub type Point4 = Point<4>;
54
55pub type Rotor2 = Rotor<2>;
56pub type Rotor3 = Rotor<3>;
57pub type Rotor4 = Rotor<4>;
58
59pub type Transform2 = Transform<2>;
60pub type Transform3 = Transform<3>;
61pub type Transform4 = Transform<4>;
62
63pub type Bivector2 = Bivector<2>;
64pub type Bivector3 = Bivector<3>;
65pub type Bivector4 = Bivector<4>;