Skip to content

Commit 84df8b9

Browse files
committed
✨ feat: tangent representations
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
1 parent 3a951d1 commit 84df8b9

35 files changed

Lines changed: 4026 additions & 47 deletions

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ pip install coordinax
3434

3535
- Specialized quantities: scalar coordinate quantities with units, including `Angle` (directional values on $S^1$ with explicit wrapping) and `Distance` (length-valued quantity), plus astronomy-facing forms like `Parallax` and `DistanceModulus`.
3636
- Charts: a coordinate chart / component schema (names + physical dimensions). A chart does not store numerical values.
37-
- Representation: geometric meaning of components, encoded as (geometry, basis, semantics), e.g. `point`.
3837
- Point: data + chart + representation, with conversion and arithmetic behavior defined by chart transition maps and tangent pushforwards.
38+
- Representation: geometric meaning of components, encoded as (geometry, basis, semantics), e.g. `point`, `coord_vel`, `phys_acc`.
3939

4040
## Modules
4141

@@ -104,6 +104,8 @@ Common representation constants are available from the high-level module:
104104
import coordinax.main as cx
105105

106106
cx.point # point location data
107+
cx.coord_vel # coordinate-basis velocity components
108+
cx.phys_vel # physical-basis velocity components
107109
```
108110

109111
### Manifolds

docs/api/charts.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ cart_of_sph = cxc.cartesian_chart(sph)
4141
- `guess_chart`: infer a chart from keys or array/quantity trailing shape
4242
- `cdict`: normalize inputs to component dictionaries
4343
- `pt_map`: transform points between charts on the same manifold
44-
- `pt_map`: general point map, including realization-style maps
45-
- `realize_cartesian`: realize point coordinates in `chart.cartesian`
44+
- `jacobian_pt_map`: general point map, including realization-style maps
4645

47-
`pt_map` is the same-manifold specialization. `pt_map` is the more general interface.
46+
`pt_map` is the same-manifold specialization. `jacobian_pt_map` is the more general interface.
4847

4948
## Available Objects
5049

docs/api/representations.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,42 @@ A representation is the triple $R = (K, B, S)$:
1010
- $B$: basis kind (how components are interpreted as basis components)
1111
- $S$: semantic kind (what the object means physically/mathematically)
1212

13-
This is separate from charts:
13+
This is separate from charts and manifolds:
1414

1515
- Charts define coordinate systems.
16+
- Manifolds define the underlying space.
1617
- Representations define geometric meaning and transformation law category.
1718

18-
In the current design, the primary built-in representation is point data.
19-
2019
## Quick Start
2120

22-
```python
23-
import coordinax.charts as cxc
24-
import coordinax.representations as cxr
21+
```pycon
22+
>>> import coordinax.charts as cxc
23+
>>> import coordinax.representations as cxr
24+
>>> import unxt as u
2525

2626
# Canonical point representation.
27-
rep = cxr.point
27+
>>> rep = cxr.point
2828

2929
# Convert point data between charts while preserving representation.
30-
p = {"x": 1.0, "y": 2.0, "z": 3.0}
31-
q = cxr.cconvert(p, cxc.cart3d, rep, cxc.sph3d, rep)
30+
>>> p = {"x": 1.0, "y": 2.0, "z": 3.0}
31+
>>> q = cxr.cconvert(p, cxc.cart3d, rep, cxc.sph3d, rep)
32+
33+
# Change tangent components between basis conventions in the same chart.
34+
>>> v = {"r": u.Q(1.0, "km/s"), "theta": u.Q(0.0, "rad/s"), "phi": u.Q(0.0, "rad/s")}
35+
>>> at = {"r": u.Q(2.0, "km"), "theta": u.Q(3.0, "rad"), "phi": u.Q(4.0, "rad")}
36+
>>> v2 = cxr.change_basis(v, cxc.cart2d, cxr.coord_basis, cxr.phys_basis, at=at)
37+
>>> v2
38+
{'r': Q(1., 'km / s'), 'theta': Q(0., 'rad / s'), 'phi': Q(0., 'rad / s')}
3239

3340
# Build a reusable conversion map.
34-
to_sph = cxr.cmap(cxc.cart3d, cxr.point, cxc.sph3d)
35-
q2 = to_sph(p)
41+
>>> to_sph = cxr.cmap(cxc.cart3d, cxr.point, cxc.sph3d)
42+
>>> q2 = to_sph(p)
3643
```
3744

3845
## Functional API
3946

4047
- `cconvert`: representation-aware coordinate conversion API
48+
- `change_basis`: same-chart tangent basis conversion API
4149
- `cmap`: partial-function builder around `cconvert`
4250
- `guess_basis_kind`: infer basis kind from dimensions/data
4351
- `guess_geometry_kind`: infer geometric kind from dimensions/data
@@ -51,6 +59,7 @@ For point data, `cconvert` dispatches through chart-level point conversion laws.
5159
### Conversion Functions
5260

5361
- `cconvert`: convert data across charts/representations
62+
- `change_basis`: change tangent basis without changing chart
5463
- `cmap`: build reusable conversion callables
5564
- `guess_basis_kind`: infer a basis kind
5665
- `guess_geometry_kind`: infer a geometry kind
@@ -73,6 +82,8 @@ For point data, `cconvert` dispatches through chart-level point conversion laws.
7382

7483
- `AbstractBasis`: base class for basis descriptors
7584
- `NoBasis` / `no_basis`: basis kind used for affine point data
85+
- `CoordinateBasis` / `coord_basis`: coordinate-basis tangent components
86+
- `PhysicalBasis` / `phys_basis`: physical-basis tangent components
7687

7788
## Semantic Kind
7889

@@ -83,6 +94,8 @@ For point data, `cconvert` dispatches through chart-level point conversion laws.
8394

8495
- Representations are orthogonal to charts: chart choice and representation choice are independent concerns.
8596
- The current built-in flow is point-first, centered on `(point_geom, no_basis, loc)`.
97+
- `change_basis` is currently limited to tangent data in Cartesian charts, with `CoordinateBasis` $
98+
ightleftarrows$ `PhysicalBasis` conversions.
8699

87100
```{eval-rst}
88101

docs/guides/representations.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,40 @@ Current built-in representation conversions are point-first:
138138

139139
The representation design is intentionally extensible. Future geometric kinds (for example tangent and cotangent objects) can use different transformation categories (such as Jacobian pushforward/pullback) while keeping the same chart and manifold interfaces.
140140

141+
## Tangent Basis Changes
142+
143+
`change_basis` handles a narrower problem than `cconvert`: it keeps the chart fixed and only changes how tangent components are interpreted with respect to a basis.
144+
145+
In the current v1 implementation, this is intentionally limited to tangent data in Cartesian charts:
146+
147+
- supported basis changes: `CoordinateBasis` $
148+
ightleftarrows$ `PhysicalBasis`
149+
- supported representations: tangent representations such as `coord_disp` and `phys_disp`
150+
- unsupported: point data (`NoBasis`) and non-Cartesian charts
151+
152+
```{code-block} python
153+
>>> import coordinax.charts as cxc
154+
>>> import coordinax.representations as cxr
155+
156+
>>> v = {"x": 1.0, "y": 0.0}
157+
>>> at = {"x": 2.0, "y": 3.0}
158+
159+
>>> cxr.change_basis(v, cxc.cart2d, cxr.coord_basis, cxr.phys_basis, at=at)
160+
{'x': 1.0, 'y': 0.0}
161+
162+
>>> cxr.change_basis(v, cxc.cart2d, cxr.coord_disp, cxr.phys_disp, at=at)
163+
{'x': 1.0, 'y': 0.0}
164+
```
165+
166+
In Cartesian charts the coordinate basis and physical basis coincide, so the component values are unchanged. The API exists so code can state basis intent explicitly and remain extensible to nontrivial basis changes later.
167+
141168
## Quick Reference
142169

143170
- Need only a same-manifold coordinate rewrite: `pt_map`
144171
- Need general point mapping behavior: `pt_map`
145172
- Need manifold compatibility checks: manifold methods like `M.pt_map`
146173
- Need representation-aware conversions: `cconvert`
174+
- Need same-chart tangent basis conversion: `change_basis`
147175
- Need reusable conversion callables: `cmap`
148176
- Need to infer basis kind from data: `guess_basis_kind`
149177
- Need to infer semantic kind from data: `guess_semantic_kind`

0 commit comments

Comments
 (0)