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 compound;
29pub mod convex_hull;
30pub mod halfspace;
31pub mod hyperbox;
32pub mod hyperplane;
33pub mod point;
34pub mod rotor;
35pub mod shape;
36pub mod sphere;
37pub mod transform;
38
39pub use bivector::Bivector;
40pub use capsule::Capsule;
41pub use compound::CompoundShape;
42pub use convex_hull::ConvexHull;
43pub use halfspace::HalfSpace;
44pub use hyperbox::HyperBox;
45pub use hyperplane::Hyperplane;
46pub use point::Point;
47pub use rotor::Rotor;
48pub use shape::Shape;
49pub use sphere::Sphere;
50pub use transform::Transform;
51
52/// Type alias for common dimension specializations.
53pub type Point2 = Point<2>;
54pub type Point3 = Point<3>;
55pub type Point4 = Point<4>;
56
57pub type Rotor2 = Rotor<2>;
58pub type Rotor3 = Rotor<3>;
59pub type Rotor4 = Rotor<4>;
60
61pub type Transform2 = Transform<2>;
62pub type Transform3 = Transform<3>;
63pub type Transform4 = Transform<4>;
64
65pub type Bivector2 = Bivector<2>;
66pub type Bivector3 = Bivector<3>;
67pub type Bivector4 = Bivector<4>;