Skip to main content

glamx/
lib.rs

1//! # glamx - Extensions for glam
2//!
3//! This crate provides additional types and utilities for the `glam` math library:
4//!
5//! - [`Rot2`] / [`DRot2`]: 2D rotations represented as unit complex numbers
6//! - [`Rot3`] / [`DRot3`]: 3D rotations (re-exports of glam's quaternions)
7//! - [`Pose2`] / [`DPose2`]: 2D rigid body transformations (rotation + translation)
8//! - [`Pose3`] / [`DPose3`]: 3D rigid body transformations (rotation + translation)
9//! - [`MatExt`]: Extension traits for glam matrix types
10//! - [`SymmetricEigen2`] / [`SymmetricEigen3`]: Eigendecomposition for symmetric matrices
11//! - [`Svd2`] / [`Svd3`]: Singular Value Decomposition for 2x2 and 3x3 matrices
12//!
13//! ## Naming Convention
14//!
15//! Types without a prefix use `f32` precision, while types with a `D` prefix use `f64` precision:
16//! - `Rot2` (f32) / `DRot2` (f64)
17//! - `Pose2` (f32) / `DPose2` (f64)
18//! - `SymmetricEigen2` (f32) / `DSymmetricEigen2` (f64)
19//!
20//! ## Feature Flags
21//!
22//! - `std` (default): Enables standard library support
23//! - `serde`: Enables serialization support via serde
24//! - `bytemuck`: Enables bytemuck derive for Rot2/DRot2
25//! - `nalgebra`: Enables conversions to/from nalgebra types
26//! - `libm`: Uses libm for no_std math operations
27//!
28//! ### Type-gating features (mirror glam 0.33)
29//!
30//! These transitively enable the matching feature on `glam`. They control which
31//! type aliases the underlying `glam` re-export exposes; glamx adds extension
32//! types only for the floating-point variants, so disabling `f64` also removes
33//! all `D*` types (DRot2, DPose2, DSymmetricEigen2, ...).
34//!
35//! - `all-types` (default): enables `float-types`, `integer-types`, `size-types`.
36//! - `float-types`: enables `f64`.
37//! - `integer-types`: enables `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`.
38//! - `size-types`: enables `isize`, `usize`.
39//! - Individual features: `f64`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`,
40//!   `u64`, `isize`, `usize`.
41//!
42//! ## glam Re-exports
43//!
44//! This crate re-exports all of glam's types so you can use it as a drop-in replacement without
45//! an explicit dependency to `glam`.
46//! Alternatively, depending on your coding style preferences, you can use the `glam` re-export.
47
48#![no_std]
49
50#[cfg(feature = "std")]
51extern crate std;
52
53// Re-export approx for convenience
54#[cfg(feature = "approx")]
55pub use approx;
56/// Re-export of the glam crate.
57pub use glam;
58
59mod eigen2;
60mod eigen3;
61mod matrix_ext;
62mod pose2;
63mod pose3;
64mod rot2;
65mod rot3;
66mod svd2;
67mod svd3;
68
69#[cfg(feature = "f64")]
70pub use eigen2::DSymmetricEigen2;
71pub use eigen2::SymmetricEigen2;
72#[cfg(feature = "f64")]
73pub use eigen3::DSymmetricEigen3;
74pub use eigen3::{SymmetricEigen3, SymmetricEigen3A};
75pub use glam::*;
76pub use matrix_ext::MatExt;
77#[cfg(feature = "f64")]
78pub use pose2::DPose2;
79pub use pose2::Pose2;
80#[cfg(feature = "f64")]
81pub use pose3::DPose3;
82pub use pose3::{Pose3, Pose3A};
83#[cfg(feature = "f64")]
84pub use rot2::DRot2;
85pub use rot2::Rot2;
86#[cfg(feature = "f64")]
87pub use rot3::DRot3;
88pub use rot3::Rot3;
89#[cfg(feature = "f64")]
90pub use svd2::DSvd2;
91pub use svd2::Svd2;
92#[cfg(feature = "f64")]
93pub use svd3::DSvd3;
94pub use svd3::{Svd3, Svd3A};
95
96/// Prelude module for convenient imports.
97///
98/// This module re-exports all public types and traits.
99pub mod prelude {
100    #[cfg(feature = "f64")]
101    pub use crate::eigen2::DSymmetricEigen2;
102    pub use crate::eigen2::SymmetricEigen2;
103    #[cfg(feature = "f64")]
104    pub use crate::eigen3::DSymmetricEigen3;
105    pub use crate::eigen3::{SymmetricEigen3, SymmetricEigen3A};
106    pub use crate::matrix_ext::MatExt;
107    #[cfg(feature = "f64")]
108    pub use crate::pose2::DPose2;
109    pub use crate::pose2::Pose2;
110    #[cfg(feature = "f64")]
111    pub use crate::pose3::DPose3;
112    pub use crate::pose3::Pose3;
113    #[cfg(feature = "f64")]
114    pub use crate::rot2::DRot2;
115    pub use crate::rot2::Rot2;
116    #[cfg(feature = "f64")]
117    pub use crate::rot3::DRot3;
118    pub use crate::rot3::Rot3;
119    #[cfg(feature = "f64")]
120    pub use crate::svd2::DSvd2;
121    pub use crate::svd2::Svd2;
122    #[cfg(feature = "f64")]
123    pub use crate::svd3::DSvd3;
124    pub use crate::svd3::{Svd3, Svd3A};
125}