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
//! # Reference Centers Module
//!
//! This module defines the concept of a *reference center* (origin) for coordinate systems.
//! A reference center specifies the origin point from which positions are measured.
//!
//! ## Overview
//!
//! The [`ReferenceCenter`] trait provides a common interface for all reference center types.
//! Each center is represented as a zero-sized struct and implements the trait to provide
//! its canonical name.
//!
//! ## Domain-Agnostic Design
//!
//! This module provides **only** the trait infrastructure. Concrete center types
//! (e.g., astronomical centers, robotic bases, reference origins) should be defined
//! in domain-specific crates that depend on `affn`.
//!
//! ## Parameterized Centers
//!
//! Some reference centers require runtime parameters. For example, a "topocentric"
//! center in astronomy needs the observer's location. This is achieved through the
//! associated `Params` type on [`ReferenceCenter`]:
//!
//! - For most centers, `Params = ()` (zero-cost).
//! - For parameterized centers, `Params` stores the required data.
//!
//! ## Creating Custom Centers
//!
//! Use the derive macro for convenient definitions:
//!
//! ```rust
//! use affn::centers::ReferenceCenter;
//!
//! #[derive(Debug, Copy, Clone)]
//! pub struct MyCenter;
//!
//! impl ReferenceCenter for MyCenter {
//! type Params = ();
//! fn center_name() -> &'static str { "MyCenter" }
//! }
//!
//! assert_eq!(MyCenter::center_name(), "MyCenter");
//! ```
//!
//! For parameterized centers, implement the trait manually.
//!
//! ## Special Markers
//!
//! - [`NoCenter`]: Marker for translation-invariant objects (free vectors).
//! - [`AffineCenter`]: Marker trait for genuine spatial centers (not `NoCenter`).
use Debug;
/// A trait for defining a reference center (coordinate origin).
///
/// # Associated Types
///
/// - `Params`: Runtime parameters for this center. Use `()` for centers that
/// don't need parameters. For parameterized centers, this carries the required data.
///
/// # Implementing
///
/// ```rust
/// use affn::centers::ReferenceCenter;
///
/// #[derive(Debug, Copy, Clone)]
/// pub struct MyCenter;
///
/// impl ReferenceCenter for MyCenter {
/// type Params = ();
/// fn center_name() -> &'static str {
/// "MyCenter"
/// }
/// }
/// ```
// =============================================================================
// Unit implementation (for generic code)
// =============================================================================
// =============================================================================
// NoCenter: Marker for translation-invariant (free) vectors
// =============================================================================
/// Marker type for translation-invariant (free) vectors.
///
/// Free vectors like directions and velocities do not have a meaningful
/// spatial origin. They represent properties that are independent of
/// any particular coordinate center:
///
/// - **Directions** are unit vectors representing orientations in space
/// - **Velocities** are rates of change that don't depend on position
///
/// Using `NoCenter` instead of a regular `ReferenceCenter` prevents
/// mathematically invalid center transformations at compile time.
/// Objects with `NoCenter` can only undergo frame transformations (rotations),
/// not center transformations (translations).
///
/// # Mathematical Rationale
///
/// In affine geometry:
/// - **Positions** are points in affine space; changing the origin (center) is a translation.
/// - **Directions** and **velocities** are elements of the underlying vector space;
/// they are translation-invariant and do not have an "origin" to change.
;
// NOTE: NoCenter deliberately does NOT implement ReferenceCenter or AffineCenter.
// This prevents center transformations on directions and velocities.
// =============================================================================
// AffineCenter: Marker for genuine spatial centers
// =============================================================================
/// Marker trait for types that represent genuine spatial centers (origins).
///
/// This trait is implemented only for center types that represent actual
/// coordinate origins. It is NOT implemented for `NoCenter`, which prevents
/// center transformations from being applied to free vectors (directions, velocities).
///
/// # Usage
///
/// Use this trait as a bound when implementing center transformations:
///
/// ```ignore
/// impl<F, U> TransformCenter<Position<C2, F, U>> for Position<C1, F, U>
/// where
/// C1: AffineCenter,
/// C2: AffineCenter,
/// // ...
/// ```