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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
//! # affn - Affine Geometry Primitives
//!
//! This crate provides strongly-typed coordinate systems with compile-time safety for
//! scientific computing applications. It defines the mathematical foundation for
//! working with positions, directions, and displacements in various reference frames.
//!
//! ## Domain-Agnostic Design
//!
//! `affn` is a **pure geometry kernel** that contains no domain-specific vocabulary.
//! Concrete frame and center types (e.g., astronomical frames, robotic frames)
//! should be defined in downstream crates that depend on `affn`.
//! See [`conic`] for the dedicated guide to the conic geometry layer.
//!
//! ## Core Concepts
//!
//! ### Reference Centers
//!
//! A [`ReferenceCenter`] defines the origin point of a coordinate system.
//! Some centers require runtime parameters (stored in `ReferenceCenter::Params`).
//!
//! ### Reference Frames
//!
//! A [`ReferenceFrame`] defines the orientation of coordinate axes.
//!
//! ### Coordinate Types
//!
//! - **Position**: An affine point in space (center + frame + distance)
//! - **Direction**: A unit vector representing orientation (frame only)
//! - **Displacement/Velocity**: Free vectors (frame + magnitude)
//! - **Conic geometry**: Reusable conic-family classification plus shape and
//! orientation containers without time or propagation semantics
//!
//! ## Creating Custom Frames and Centers
//!
//! Use derive macros for convenient definitions:
//!
//! ```rust
//! use affn::prelude::*;
//!
//! #[derive(Debug, Copy, Clone, ReferenceFrame)]
//! struct MyFrame;
//!
//! #[derive(Debug, Copy, Clone, ReferenceCenter)]
//! struct MyCenter;
//!
//! assert_eq!(MyFrame::frame_name(), "MyFrame");
//! assert_eq!(MyCenter::center_name(), "MyCenter");
//! ```
//!
//! Typos in derive attributes are compile errors:
//!
//! ```compile_fail
//! use affn::prelude::*;
//!
//! #[derive(Debug, Copy, Clone, ReferenceFrame)]
//! #[frame(azimth = "Equatorial")] // typo: should be "name"
//! struct BadFrame;
//! ```
//!
//! ```compile_fail
//! use affn::prelude::*;
//!
//! #[derive(Debug, Copy, Clone, ReferenceCenter)]
//! #[center(nme = "Earth")] // typo: should be "name"
//! struct BadCenter;
//! ```
//!
//! ## Algebraic Rules
//!
//! The type system enforces mathematical correctness:
//!
//! | Operation | Result | Meaning |
//! |-----------|--------|---------|
//! | `Position - Position` | `Displacement` | Displacement between points |
//! | `Position + Displacement` | `Position` | Translate point |
//! | `Displacement + Displacement` | `Displacement` | Add displacements |
//! | `Direction * Length` | `Displacement` | Scale direction |
//! | `normalize(Displacement)` | `Direction` | Extract orientation |
//!
//! ## Example
//!
//! ```rust
//! use affn::cartesian::{Position, Displacement};
//! use affn::frames::ReferenceFrame;
//! use affn::centers::ReferenceCenter;
//! use affn::qtty::units::Kilometer;
//!
//! // Define domain-specific types
//! #[derive(Debug, Copy, Clone)]
//! struct WorldFrame;
//! impl ReferenceFrame for WorldFrame {
//! fn frame_name() -> &'static str { "WorldFrame" }
//! }
//!
//! #[derive(Debug, Copy, Clone)]
//! struct WorldOrigin;
//! impl ReferenceCenter for WorldOrigin {
//! type Params = ();
//! fn center_name() -> &'static str { "WorldOrigin" }
//! }
//!
//! let a = Position::<WorldOrigin, WorldFrame, Kilometer>::new(100.0, 200.0, 300.0);
//! let b = Position::<WorldOrigin, WorldFrame, Kilometer>::new(150.0, 250.0, 350.0);
//!
//! // Positions subtract to give displacements
//! let displacement: Displacement<WorldFrame, Kilometer> = b - a;
//! ```
//!
//! ## Units via `qtty`
//!
//! Lengths, angles, and related quantities in `affn`'s public API use
//! [`qtty`](https://docs.rs/qtty) types. Prefer the re-exported
//! [`affn::qtty`](crate::qtty) path so you always get the same `qtty`
//! instance that `affn` was compiled against:
//!
//! ```rust
//! use affn::qtty::units::Meter;
//! use affn::qtty::{Quantity, M};
//! ```
//!
//! Re-exporting does **not** force Cargo to unify incompatible `qtty`
//! versions if another crate depends on a semver-incompatible release;
//! crates that exchange `qtty` values should still agree on compatible
//! dependency ranges. An incompatible `qtty` upgrade is treated as a
//! potentially breaking change for `affn`.
// Allow the crate to refer to itself as `::affn::` for derive macro compatibility
extern crate self as affn;
// Internal `Display`/`LowerExp`/`UpperExp` triplet macro. Must precede any
// modules that use it.
// Coordinate type implementations
// Core traits and marker types
// Ellipsoid definitions and frame-ellipsoid association
// Ellipsoidal coordinate system (lon, lat, height-above-ellipsoid)
// Affine operators (rotation, translation, isometry)
// Typed inter-reference-system transforms (not re-exported at crate root /
// prelude to avoid colliding with domain crates that define their own
// `Transform` traits — e.g. siderust).
// Shared serde utilities
pub
// Frame-tagged 3×3 matrix primitives
// Frame-tagged 6×6 matrix and block-diagonal rotation helper
// Re-export derive macros from affn-derive
// Named with Derive prefix to avoid conflicts with trait names
pub use ;
/// Re-export of the [`qtty`] crate used by `affn`'s public API.
///
/// Prefer `affn::qtty` over a separate direct `qtty` dependency when
/// constructing quantities for `affn` types, so values share the same
/// crate instance that `affn` was compiled against.
///
/// This re-export does not prevent Cargo from resolving a second,
/// semver-incompatible `qtty` if another crate depends on one explicitly.
pub use qtty;
// Re-export traits at crate level with their original names
// This is the standard pattern: traits and derives co-exist with same names
pub use ;
pub use ReferenceFrame;
// Re-export operators at crate level
pub use ;
// Re-export concrete Position/Direction types for standalone usage
pub use ;
pub use ;
pub use ;
// Re-export ellipsoidal Position for standalone usage
pub use ;
/// Prelude module for convenient imports.
///
/// Import everything you need with:
/// ```rust
/// use affn::prelude::*;
/// ```