1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//!
//! # For Linear Algebra Users
//!
//! If you know linear algebra, you're already halfway to understanding Geometric Algebra (GA).
//! This section maps concepts you know to their GA equivalents.
//!
//! ## From Vectors to Blades
//!
//! In LA, you work with vectors. In GA, vectors are just one type of **blade**:
//!
//! | Grade | Name | LA Analogue | Geometric Meaning |
//! |-------|------|-------------|-------------------|
//! | 0 | Scalar | Real number | Magnitude, no direction |
//! | 1 | Vector | Vector in R^n | Directed line segment |
//! | 2 | Bivector | (no direct equivalent) | Oriented plane segment |
//! | 3 | Trivector | (no direct equivalent) | Oriented volume |
//! | n | Pseudoscalar | Determinant (sort of) | Oriented n-volume |
//!
//! **Key insight**: The cross product `a × b` in 3D actually produces a bivector
//! (oriented plane), not a vector. The "vector" you get is the **dual** of that plane.
//!
//! ## From Products to the Geometric Product
//!
//! In LA, you have separate operations: dot product, cross product, matrix multiplication.
//! In GA, the **geometric product** unifies them:
//!
//! ```text
//! a * b = a·b + a∧b
//! = (inner product) + (outer product)
//! = (scalar part) + (bivector part)
//! ```
//!
//! | LA Operation | GA Equivalent | Result |
//! |--------------|---------------|--------|
//! | Dot product `a·b` | Inner product | Scalar (grade 0) |
//! | Cross product `a×b` | `*(a∧b)` (dual of wedge) | Vector (grade 1) |
//! | Matrix multiply | Geometric product | Mixed grades |
//!
//! ## From Rotations to Rotors
//!
//! This is where GA really shines. Rotations are represented by **rotors**:
//!
//! | Dimension | LA Representation | GA Representation |
//! |-----------|-------------------|-------------------|
//! | 2D | 2×2 rotation matrix | Rotor (scalar + bivector) |
//! | 2D | Complex number `e^{iθ}` | Rotor `cos(θ/2) + sin(θ/2)e₁₂` |
//! | 3D | 3×3 rotation matrix | Rotor (scalar + bivector) |
//! | 3D | Quaternion | Rotor `s + xy·e₁₂ + xz·e₁₃ + yz·e₂₃` |
//! | nD | SO(n) matrix | Rotor (even-grade multivector) |
//!
//! **Quaternions ARE rotors!** The imaginary units i, j, k are bivectors e₂₃, e₃₁, e₁₂.
//!
//! ## Module Guide
//!
//! - [`algebra`]: Generic [`Multivector`](algebra::Multivector) for any metric signature.
//! Use when you need maximum flexibility or exotic algebras.
//!
//! - [`specialized::euclidean`]: Optimized types for 2D/3D Euclidean geometry.
//! Use for standard vector math, rotations, reflections.
//!
//! - [`specialized::projective`]: Projective GA (PGA) for rigid body transforms.
//! Use when you need unified rotation + translation (like 4×4 matrices, but better).
//!
//! - [`basis`]: Low-level blade representation. Rarely needed directly.
//!
//! - [`signature`]: Metric signatures defining the algebra. Use [`prelude`] instead.
//!
//! ## Quick Decision Guide
//!
//! | Task | Recommended Module |
//! |------|-------------------|
//! | 2D/3D rotations | [`specialized::euclidean`] |
//! | Rigid body transforms | [`specialized::projective`] |
//! | Robotics kinematics | [`specialized::projective`] |
//! | Graphics transforms | [`specialized::projective`] |
//! | Physics simulations | [`algebra`] with appropriate signature |
//! | Learning GA | Start with [`specialized::euclidean::dim3`] |
//!
// Ensure nalgebra feature flags are mutually exclusive
compile_error!;
// ============================================================================
// Error Types
// ============================================================================
/// Error returned when a geometric constraint is not satisfied.
///
/// This error is returned by `new_checked()` constructors on constrained types
/// (like `Motor`, `Bivector`, `Flector` in PGA) when the provided coefficients
/// violate the geometric constraint.
///
/// # Example
///
/// ```ignore
/// use clifford::generated::projective3::Motor;
///
/// // Valid motor - constraint satisfied
/// let m = Motor::new(1.0, 0.1, 0.2, 0.3, 0.01, 0.02, 0.03);
///
/// // Check with explicit coefficients
/// let result = Motor::new_checked(1.0, 0.1, 0.2, 0.3, 0.01, 0.02, 0.03, 999.0, 1e-10);
/// assert!(result.is_err()); // e0123 = 999.0 violates constraint
/// ```
/// Test utilities available only during testing.
pub