coordinate-system 2.4.0__tar.gz → 2.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. {coordinate_system-2.4.0/coordinate_system.egg-info → coordinate_system-2.4.2}/PKG-INFO +2 -150
  2. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/README.md +1 -149
  3. {coordinate_system-2.4.0 → coordinate_system-2.4.2/coordinate_system.egg-info}/PKG-INFO +2 -150
  4. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/coordinate_system_binding.cpp +14 -38
  5. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/pmsys_minimal.hpp +45 -136
  6. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/setup.py +2 -2
  7. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/LICENSE +0 -0
  8. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/MANIFEST.in +0 -0
  9. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/MATHEMATICAL_FOUNDATION.md +0 -0
  10. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/coordinate_system/__init__.py +0 -0
  11. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/coordinate_system/curvature.py +0 -0
  12. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/coordinate_system/differential_geometry.py +0 -0
  13. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/coordinate_system/two_stage_curvature.py +0 -0
  14. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/coordinate_system.egg-info/SOURCES.txt +0 -0
  15. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/coordinate_system.egg-info/dependency_links.txt +0 -0
  16. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/coordinate_system.egg-info/not-zip-safe +0 -0
  17. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/coordinate_system.egg-info/top_level.txt +0 -0
  18. {coordinate_system-2.4.0 → coordinate_system-2.4.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: coordinate_system
3
- Version: 2.4.0
3
+ Version: 2.4.2
4
4
  Summary: High-performance 3D coordinate system library with machine-precision Gaussian curvature computation (0.000% error) using corrected antisymmetric extraction formula
5
5
  Home-page: https://github.com/panguojun/Coordinate-System
6
6
  Author: PanGuoJun
@@ -48,7 +48,7 @@ License-File: LICENSE
48
48
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
49
49
 
50
50
  **Author:** PanGuoJun
51
- **Version:** 2.4.0
51
+ **Version:** 2.4.1
52
52
  **License:** MIT
53
53
 
54
54
  ## 🆕 What's New in v2.4.0
@@ -99,154 +99,6 @@ Perfect for computational geometry, geometric analysis, and discrete differentia
99
99
 
100
100
  ---
101
101
 
102
- ## 🆕 Differential Geometry (NEW in v2.2.0)
103
-
104
- ### Surface Representation
105
-
106
- ```python
107
- from coordinate_system import Sphere, Torus, Surface
108
-
109
- # Create a sphere
110
- sphere = Sphere(radius=2.0)
111
-
112
- # Create a torus
113
- torus = Torus(major_radius=3.0, minor_radius=1.0)
114
-
115
- # Or define your own surface by subclassing Surface
116
- class MySurface(Surface):
117
- def position(self, u, v):
118
- # Return vec3(x, y, z) for parameters (u, v)
119
- pass
120
- ```
121
-
122
- ### Metric Tensor (First Fundamental Form)
123
-
124
- ```python
125
- from coordinate_system import compute_metric
126
- import math
127
-
128
- # Compute metric tensor at a point
129
- g = compute_metric(sphere, u=math.pi/4, v=math.pi/3)
130
-
131
- print(f"E = {g.E:.6f}") # u-direction metric
132
- print(f"F = {g.F:.6f}") # cross term (0 if orthogonal)
133
- print(f"G = {g.G:.6f}") # v-direction metric
134
- print(f"det(g) = {g.det:.6f}")
135
- print(f"Metric correction = {g.correction_factor():.6f}")
136
- ```
137
-
138
- ### Connection Operator (Intrinsic Gradient)
139
-
140
- ```python
141
- from coordinate_system import compute_connection
142
-
143
- # Compute connection operator (frame derivative)
144
- G_u = compute_connection(sphere, u=math.pi/4, v=math.pi/3, direction='u')
145
- G_v = compute_connection(sphere, u=math.pi/4, v=math.pi/3, direction='v')
146
-
147
- print(f"G_u norm: {G_u.norm():.8f}")
148
- print(f"G_v norm: {G_v.norm():.8f}")
149
- ```
150
-
151
- **Aliases available:**
152
- - `compute_frame_derivative` (standard mathematical term)
153
- - `compute_intrinsic_gradient` (intuitive name)
154
- - `compute_geometric_gradient` (alternative)
155
-
156
- ### Curvature Tensor
157
-
158
- ```python
159
- from coordinate_system import compute_curvature_tensor
160
-
161
- # Compute complete curvature tensor R_uv
162
- R_uv = compute_curvature_tensor(
163
- sphere,
164
- u=math.pi/4,
165
- v=math.pi/3,
166
- use_lie_derivative=True # CRITICAL for accuracy!
167
- )
168
-
169
- print(f"Curvature tensor norm: {R_uv.norm():.8f}")
170
-
171
- # R_uv is a 3×3 coord3 object with structure:
172
- # [[R_11, R_12, R_13], ← Tangent-tangent (intrinsic)
173
- # [R_21, R_22, R_23], ← Tangent-normal (second fundamental form)
174
- # [R_31, R_32, R_33]] ← Normal-normal (extrinsic)
175
- ```
176
-
177
- ### Gaussian Curvature (Quickest Method)
178
-
179
- ```python
180
- from coordinate_system import Sphere, compute_gaussian_curvature
181
- import math
182
-
183
- # One-line curvature computation!
184
- sphere = Sphere(radius=2.0)
185
- K = compute_gaussian_curvature(sphere, u=math.pi/4, v=math.pi/3)
186
-
187
- print(f"Gaussian curvature K = {K:.6f}")
188
- # Expected: K = 1/R² = 0.25 for a sphere
189
-
190
- # Theoretical value
191
- K_theory = 1.0 / (2.0 ** 2)
192
- error = abs(K - K_theory) / K_theory * 100
193
- print(f"Relative error: {error:.2f}%") # Typically < 3% !
194
- ```
195
-
196
- ### Accuracy Comparison
197
-
198
- **On a sphere with radius R=2 (24 test points across different angles):**
199
-
200
- | Method | Antisymmetric Extraction | Accuracy | Notes |
201
- |--------|-------------------------|----------|-------|
202
- | Old (R_10 only) | ❌ | ~2.5% error | Previous versions |
203
- | **v2.4.0 (Corrected)** | ✓ | **0.000% error** | **Machine precision!** 🎉 |
204
-
205
- **Key Formula:** `K = (R_01 - R_10) / (2 · det(g))`
206
-
207
- The antisymmetric part `(R_01 - R_10)/2` correctly eliminates metric influence and extracts pure curvature. This formula is verified against traditional Christoffel symbol methods and achieves identical results at machine precision (< 10⁻¹⁵ error).
208
-
209
- ### Key Parameters
210
-
211
- ```python
212
- # For constant curvature surfaces (spheres):
213
- K = compute_gaussian_curvature(
214
- surface,
215
- u, v,
216
- scale_factor=2.0, # Optimal for spheres
217
- use_metric_correction=True, # Essential!
218
- use_lie_derivative=True # Critical for accuracy!
219
- )
220
-
221
- # These are the default values, optimized for best accuracy
222
- ```
223
-
224
- ### Complete Example
225
-
226
- See `examples/curvature_computation.py` for comprehensive demonstrations, or `examples/quickstart.py` for the simplest possible usage.
227
-
228
- ```python
229
- # examples/quickstart.py
230
- import math
231
- from coordinate_system import Sphere, compute_gaussian_curvature
232
-
233
- # Step 1: Create a sphere
234
- sphere = Sphere(radius=2.0)
235
-
236
- # Step 2: Choose a point
237
- u, v = math.pi/4, math.pi/3
238
-
239
- # Step 3: Compute curvature (one line!)
240
- K = compute_gaussian_curvature(sphere, u, v)
241
-
242
- # Step 4: Compare with theory
243
- K_theory = 1.0 / (2.0 ** 2) # K = 1/R²
244
- print(f"Computed: K = {K:.6f}")
245
- print(f"Theory: K = {K_theory:.6f}")
246
- print(f"Error: {abs(K-K_theory)/K_theory*100:.2f}%")
247
- ```
248
-
249
- ---
250
102
 
251
103
  ## 📚 Documentation
252
104
 
@@ -8,7 +8,7 @@
8
8
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
9
9
 
10
10
  **Author:** PanGuoJun
11
- **Version:** 2.4.0
11
+ **Version:** 2.4.1
12
12
  **License:** MIT
13
13
 
14
14
  ## 🆕 What's New in v2.4.0
@@ -59,154 +59,6 @@ Perfect for computational geometry, geometric analysis, and discrete differentia
59
59
 
60
60
  ---
61
61
 
62
- ## 🆕 Differential Geometry (NEW in v2.2.0)
63
-
64
- ### Surface Representation
65
-
66
- ```python
67
- from coordinate_system import Sphere, Torus, Surface
68
-
69
- # Create a sphere
70
- sphere = Sphere(radius=2.0)
71
-
72
- # Create a torus
73
- torus = Torus(major_radius=3.0, minor_radius=1.0)
74
-
75
- # Or define your own surface by subclassing Surface
76
- class MySurface(Surface):
77
- def position(self, u, v):
78
- # Return vec3(x, y, z) for parameters (u, v)
79
- pass
80
- ```
81
-
82
- ### Metric Tensor (First Fundamental Form)
83
-
84
- ```python
85
- from coordinate_system import compute_metric
86
- import math
87
-
88
- # Compute metric tensor at a point
89
- g = compute_metric(sphere, u=math.pi/4, v=math.pi/3)
90
-
91
- print(f"E = {g.E:.6f}") # u-direction metric
92
- print(f"F = {g.F:.6f}") # cross term (0 if orthogonal)
93
- print(f"G = {g.G:.6f}") # v-direction metric
94
- print(f"det(g) = {g.det:.6f}")
95
- print(f"Metric correction = {g.correction_factor():.6f}")
96
- ```
97
-
98
- ### Connection Operator (Intrinsic Gradient)
99
-
100
- ```python
101
- from coordinate_system import compute_connection
102
-
103
- # Compute connection operator (frame derivative)
104
- G_u = compute_connection(sphere, u=math.pi/4, v=math.pi/3, direction='u')
105
- G_v = compute_connection(sphere, u=math.pi/4, v=math.pi/3, direction='v')
106
-
107
- print(f"G_u norm: {G_u.norm():.8f}")
108
- print(f"G_v norm: {G_v.norm():.8f}")
109
- ```
110
-
111
- **Aliases available:**
112
- - `compute_frame_derivative` (standard mathematical term)
113
- - `compute_intrinsic_gradient` (intuitive name)
114
- - `compute_geometric_gradient` (alternative)
115
-
116
- ### Curvature Tensor
117
-
118
- ```python
119
- from coordinate_system import compute_curvature_tensor
120
-
121
- # Compute complete curvature tensor R_uv
122
- R_uv = compute_curvature_tensor(
123
- sphere,
124
- u=math.pi/4,
125
- v=math.pi/3,
126
- use_lie_derivative=True # CRITICAL for accuracy!
127
- )
128
-
129
- print(f"Curvature tensor norm: {R_uv.norm():.8f}")
130
-
131
- # R_uv is a 3×3 coord3 object with structure:
132
- # [[R_11, R_12, R_13], ← Tangent-tangent (intrinsic)
133
- # [R_21, R_22, R_23], ← Tangent-normal (second fundamental form)
134
- # [R_31, R_32, R_33]] ← Normal-normal (extrinsic)
135
- ```
136
-
137
- ### Gaussian Curvature (Quickest Method)
138
-
139
- ```python
140
- from coordinate_system import Sphere, compute_gaussian_curvature
141
- import math
142
-
143
- # One-line curvature computation!
144
- sphere = Sphere(radius=2.0)
145
- K = compute_gaussian_curvature(sphere, u=math.pi/4, v=math.pi/3)
146
-
147
- print(f"Gaussian curvature K = {K:.6f}")
148
- # Expected: K = 1/R² = 0.25 for a sphere
149
-
150
- # Theoretical value
151
- K_theory = 1.0 / (2.0 ** 2)
152
- error = abs(K - K_theory) / K_theory * 100
153
- print(f"Relative error: {error:.2f}%") # Typically < 3% !
154
- ```
155
-
156
- ### Accuracy Comparison
157
-
158
- **On a sphere with radius R=2 (24 test points across different angles):**
159
-
160
- | Method | Antisymmetric Extraction | Accuracy | Notes |
161
- |--------|-------------------------|----------|-------|
162
- | Old (R_10 only) | ❌ | ~2.5% error | Previous versions |
163
- | **v2.4.0 (Corrected)** | ✓ | **0.000% error** | **Machine precision!** 🎉 |
164
-
165
- **Key Formula:** `K = (R_01 - R_10) / (2 · det(g))`
166
-
167
- The antisymmetric part `(R_01 - R_10)/2` correctly eliminates metric influence and extracts pure curvature. This formula is verified against traditional Christoffel symbol methods and achieves identical results at machine precision (< 10⁻¹⁵ error).
168
-
169
- ### Key Parameters
170
-
171
- ```python
172
- # For constant curvature surfaces (spheres):
173
- K = compute_gaussian_curvature(
174
- surface,
175
- u, v,
176
- scale_factor=2.0, # Optimal for spheres
177
- use_metric_correction=True, # Essential!
178
- use_lie_derivative=True # Critical for accuracy!
179
- )
180
-
181
- # These are the default values, optimized for best accuracy
182
- ```
183
-
184
- ### Complete Example
185
-
186
- See `examples/curvature_computation.py` for comprehensive demonstrations, or `examples/quickstart.py` for the simplest possible usage.
187
-
188
- ```python
189
- # examples/quickstart.py
190
- import math
191
- from coordinate_system import Sphere, compute_gaussian_curvature
192
-
193
- # Step 1: Create a sphere
194
- sphere = Sphere(radius=2.0)
195
-
196
- # Step 2: Choose a point
197
- u, v = math.pi/4, math.pi/3
198
-
199
- # Step 3: Compute curvature (one line!)
200
- K = compute_gaussian_curvature(sphere, u, v)
201
-
202
- # Step 4: Compare with theory
203
- K_theory = 1.0 / (2.0 ** 2) # K = 1/R²
204
- print(f"Computed: K = {K:.6f}")
205
- print(f"Theory: K = {K_theory:.6f}")
206
- print(f"Error: {abs(K-K_theory)/K_theory*100:.2f}%")
207
- ```
208
-
209
- ---
210
62
 
211
63
  ## 📚 Documentation
212
64
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: coordinate_system
3
- Version: 2.4.0
3
+ Version: 2.4.2
4
4
  Summary: High-performance 3D coordinate system library with machine-precision Gaussian curvature computation (0.000% error) using corrected antisymmetric extraction formula
5
5
  Home-page: https://github.com/panguojun/Coordinate-System
6
6
  Author: PanGuoJun
@@ -48,7 +48,7 @@ License-File: LICENSE
48
48
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
49
49
 
50
50
  **Author:** PanGuoJun
51
- **Version:** 2.4.0
51
+ **Version:** 2.4.1
52
52
  **License:** MIT
53
53
 
54
54
  ## 🆕 What's New in v2.4.0
@@ -99,154 +99,6 @@ Perfect for computational geometry, geometric analysis, and discrete differentia
99
99
 
100
100
  ---
101
101
 
102
- ## 🆕 Differential Geometry (NEW in v2.2.0)
103
-
104
- ### Surface Representation
105
-
106
- ```python
107
- from coordinate_system import Sphere, Torus, Surface
108
-
109
- # Create a sphere
110
- sphere = Sphere(radius=2.0)
111
-
112
- # Create a torus
113
- torus = Torus(major_radius=3.0, minor_radius=1.0)
114
-
115
- # Or define your own surface by subclassing Surface
116
- class MySurface(Surface):
117
- def position(self, u, v):
118
- # Return vec3(x, y, z) for parameters (u, v)
119
- pass
120
- ```
121
-
122
- ### Metric Tensor (First Fundamental Form)
123
-
124
- ```python
125
- from coordinate_system import compute_metric
126
- import math
127
-
128
- # Compute metric tensor at a point
129
- g = compute_metric(sphere, u=math.pi/4, v=math.pi/3)
130
-
131
- print(f"E = {g.E:.6f}") # u-direction metric
132
- print(f"F = {g.F:.6f}") # cross term (0 if orthogonal)
133
- print(f"G = {g.G:.6f}") # v-direction metric
134
- print(f"det(g) = {g.det:.6f}")
135
- print(f"Metric correction = {g.correction_factor():.6f}")
136
- ```
137
-
138
- ### Connection Operator (Intrinsic Gradient)
139
-
140
- ```python
141
- from coordinate_system import compute_connection
142
-
143
- # Compute connection operator (frame derivative)
144
- G_u = compute_connection(sphere, u=math.pi/4, v=math.pi/3, direction='u')
145
- G_v = compute_connection(sphere, u=math.pi/4, v=math.pi/3, direction='v')
146
-
147
- print(f"G_u norm: {G_u.norm():.8f}")
148
- print(f"G_v norm: {G_v.norm():.8f}")
149
- ```
150
-
151
- **Aliases available:**
152
- - `compute_frame_derivative` (standard mathematical term)
153
- - `compute_intrinsic_gradient` (intuitive name)
154
- - `compute_geometric_gradient` (alternative)
155
-
156
- ### Curvature Tensor
157
-
158
- ```python
159
- from coordinate_system import compute_curvature_tensor
160
-
161
- # Compute complete curvature tensor R_uv
162
- R_uv = compute_curvature_tensor(
163
- sphere,
164
- u=math.pi/4,
165
- v=math.pi/3,
166
- use_lie_derivative=True # CRITICAL for accuracy!
167
- )
168
-
169
- print(f"Curvature tensor norm: {R_uv.norm():.8f}")
170
-
171
- # R_uv is a 3×3 coord3 object with structure:
172
- # [[R_11, R_12, R_13], ← Tangent-tangent (intrinsic)
173
- # [R_21, R_22, R_23], ← Tangent-normal (second fundamental form)
174
- # [R_31, R_32, R_33]] ← Normal-normal (extrinsic)
175
- ```
176
-
177
- ### Gaussian Curvature (Quickest Method)
178
-
179
- ```python
180
- from coordinate_system import Sphere, compute_gaussian_curvature
181
- import math
182
-
183
- # One-line curvature computation!
184
- sphere = Sphere(radius=2.0)
185
- K = compute_gaussian_curvature(sphere, u=math.pi/4, v=math.pi/3)
186
-
187
- print(f"Gaussian curvature K = {K:.6f}")
188
- # Expected: K = 1/R² = 0.25 for a sphere
189
-
190
- # Theoretical value
191
- K_theory = 1.0 / (2.0 ** 2)
192
- error = abs(K - K_theory) / K_theory * 100
193
- print(f"Relative error: {error:.2f}%") # Typically < 3% !
194
- ```
195
-
196
- ### Accuracy Comparison
197
-
198
- **On a sphere with radius R=2 (24 test points across different angles):**
199
-
200
- | Method | Antisymmetric Extraction | Accuracy | Notes |
201
- |--------|-------------------------|----------|-------|
202
- | Old (R_10 only) | ❌ | ~2.5% error | Previous versions |
203
- | **v2.4.0 (Corrected)** | ✓ | **0.000% error** | **Machine precision!** 🎉 |
204
-
205
- **Key Formula:** `K = (R_01 - R_10) / (2 · det(g))`
206
-
207
- The antisymmetric part `(R_01 - R_10)/2` correctly eliminates metric influence and extracts pure curvature. This formula is verified against traditional Christoffel symbol methods and achieves identical results at machine precision (< 10⁻¹⁵ error).
208
-
209
- ### Key Parameters
210
-
211
- ```python
212
- # For constant curvature surfaces (spheres):
213
- K = compute_gaussian_curvature(
214
- surface,
215
- u, v,
216
- scale_factor=2.0, # Optimal for spheres
217
- use_metric_correction=True, # Essential!
218
- use_lie_derivative=True # Critical for accuracy!
219
- )
220
-
221
- # These are the default values, optimized for best accuracy
222
- ```
223
-
224
- ### Complete Example
225
-
226
- See `examples/curvature_computation.py` for comprehensive demonstrations, or `examples/quickstart.py` for the simplest possible usage.
227
-
228
- ```python
229
- # examples/quickstart.py
230
- import math
231
- from coordinate_system import Sphere, compute_gaussian_curvature
232
-
233
- # Step 1: Create a sphere
234
- sphere = Sphere(radius=2.0)
235
-
236
- # Step 2: Choose a point
237
- u, v = math.pi/4, math.pi/3
238
-
239
- # Step 3: Compute curvature (one line!)
240
- K = compute_gaussian_curvature(sphere, u, v)
241
-
242
- # Step 4: Compare with theory
243
- K_theory = 1.0 / (2.0 ** 2) # K = 1/R²
244
- print(f"Computed: K = {K:.6f}")
245
- print(f"Theory: K = {K_theory:.6f}")
246
- print(f"Error: {abs(K-K_theory)/K_theory*100:.2f}%")
247
- ```
248
-
249
- ---
250
102
 
251
103
  ## 📚 Documentation
252
104
 
@@ -397,51 +397,27 @@ PYBIND11_MODULE(coordinate_system, m) {
397
397
  return coord3(vec3::ZERO, q);
398
398
  }, "Create coordinate system at origin with rotation", py::arg("rotation"))
399
399
 
400
- // Differential Geometry - Connection Operator (Intrinsic Gradient)
401
- .def("compute_metric_det", &coord3::compute_metric_det,
400
+ // Differential Geometry
401
+ .def("metric", &coord3::metric,
402
402
  "Compute metric tensor determinant: det(g) = E*G - F²\n\n"
403
403
  "For a parametric surface, the first fundamental form is g = [[E, F], [F, G]].\n"
404
- "Returns det(g) = E*G - F² which appears in Gaussian curvature formula.")
405
- .def_static("connection_operator_base", &coord3::connection_operator_base,
406
- "Compute base connection operator: G' = (c2*c1^-1)/C2 - I/C1\n\n"
407
- "This is the fundamental discrete connection operator formula.\n"
408
- "G' represents the discrete covariant derivative of the frame field.\n\n"
409
- "Args:\n"
410
- " c1: coordinate frame at point (u, v)\n"
411
- " c2: coordinate frame at point (u+h, v) or (u, v+h)\n"
412
- " C1: scale factor at c1\n"
413
- " C2: scale factor at c2\n\n"
414
- "Returns:\n"
415
- " G' (base connection operator as coord3)",
416
- py::arg("c1"), py::arg("c2"), py::arg("C1"), py::arg("C2"))
417
- .def_static("connection_operator", &coord3::connection_operator,
418
- "Compute connection operator with corrections: G = f(G')\n\n"
419
- "Applies scale correction and optional metric correction to G'.\n\n"
420
- "Args:\n"
421
- " c1: coordinate frame at point (u, v)\n"
422
- " c2: coordinate frame at point (u+h, v) or (u, v+h)\n"
423
- " C1: scale factor at c1\n"
424
- " C2: scale factor at c2\n"
425
- " scale_factor: overall scale multiplier (optimal: 2.0 for spheres)\n"
426
- " use_metric_correction: if true, applies 1/√det(g) correction\n\n"
427
- "Returns:\n"
428
- " G (corrected connection operator)\n\n"
429
- "For constant curvature surfaces (spheres), optimal parameters are:\n"
430
- " - scale_factor = 2.0\n"
431
- " - use_metric_correction = true\n"
432
- " - This achieves ~2.22% accuracy in Gaussian curvature computation",
433
- py::arg("c1"), py::arg("c2"), py::arg("C1"), py::arg("C2"),
434
- py::arg("scale_factor") = 2.0, py::arg("use_metric_correction") = true)
404
+ "Returns det(g) = E*G - F² which appears in Gaussian curvature formula.")
405
+
406
+ .def("metric_det", &coord3::metric_det,
407
+ "Compute metric tensor determinant: det(g) = E*G - F²\n\n"
408
+ "For a parametric surface, the first fundamental form is g = [[E, F], [F, G]].\n"
409
+ "Returns det(g) = E*G - F² which appears in Gaussian curvature formula.")
410
+
435
411
  .def_static("lie_bracket", &coord3::lie_bracket,
436
- "Compute Lie bracket [G_u, G_v] = G_u * G_v - G_v * G_u\n\n"
412
+ "Compute Lie bracket [A, B] = A * B - B * A\n\n"
437
413
  "The Lie bracket measures the non-commutativity of the connection operators.\n"
438
414
  "It appears in the curvature tensor formula as the Lie derivative term.\n\n"
439
415
  "Args:\n"
440
- " G_u: connection operator in u-direction\n"
441
- " G_v: connection operator in v-direction\n\n"
416
+ " A: connection operator in u-direction\n"
417
+ " B: connection operator in v-direction\n\n"
442
418
  "Returns:\n"
443
- " [G_u, G_v] (Lie bracket as coord3)",
444
- py::arg("G_u"), py::arg("G_v"));
419
+ " [A, B] (Lie bracket as coord3)",
420
+ py::arg("A"), py::arg("B"));
445
421
 
446
422
  // ===========================================================================
447
423
  // Utility Functions
@@ -3762,15 +3762,9 @@ struct coord3 : vcoord3
3762
3762
  }
3763
3763
 
3764
3764
  // ============================================================================
3765
- // 几何运算:梯度、插值、距离等
3765
+ // 几何运算:插值、距离等
3766
3766
  // ============================================================================
3767
- // 梯度坐标系:用于计算联络
3768
- // V2 - V1 = V1 * G, 其中 G = C2 / C1 - I
3769
- static coord3 grad(const coord3& c1, const coord3& c2)
3770
- {
3771
- return c2 / c1 - ONE;
3772
- }
3773
-
3767
+
3774
3768
  // 线性插值:位置和旋转的独立插值
3775
3769
  static coord3 lerp(const coord3& c1, const coord3& c2, real t)
3776
3770
  {
@@ -3802,6 +3796,48 @@ struct coord3 : vcoord3
3802
3796
  {
3803
3797
  return Q().angle_to(other.Q());
3804
3798
  }
3799
+
3800
+ // ============================================================================
3801
+ // 曲率计算
3802
+ // ============================================================================
3803
+ // 梯度坐标系
3804
+ // V2 - V1 = V1 * G, 其中 G = C2 / C1 - I
3805
+ static coord3 grad(const coord3& c1, const coord3& c2)
3806
+ {
3807
+ return c2 / c1 - ONE;
3808
+ }
3809
+
3810
+ vec3 metric() const
3811
+ {
3812
+ // 对于曲面,我们通常只关心 u,v 方向的切向量
3813
+ vec3 vx = VX(); // ∂r/∂u 方向
3814
+ vec3 vy = VY(); // ∂r/∂v 方向
3815
+
3816
+ real E = vx.dot(vx); // g_uu = ∂r/∂u · ∂r/∂u
3817
+ real F = vx.dot(vy); // g_uv = ∂r/∂u · ∂r/∂v
3818
+ real G = vy.dot(vy); // g_vv = ∂r/∂v · ∂r/∂v
3819
+
3820
+ return vec3(E, F, G);
3821
+ }
3822
+ // 计算第一基本形式的行列式
3823
+ real metric_det() const
3824
+ {
3825
+ vec3 vx = VX();
3826
+ vec3 vy = VY();
3827
+ vec3 vz = VZ(); // 这个vz不应该参与2D曲面计算!
3828
+
3829
+ real E = vx.dot(vx);
3830
+ real F = vx.dot(vy);
3831
+ real G = vy.dot(vy);
3832
+
3833
+ return E * G - F * F;
3834
+ }
3835
+
3836
+ static coord3 lie_bracket(const coord3& A, const coord3& B) {
3837
+ // [A, B] = A * B - B * A
3838
+ return A * B - B * A; // 需要正确定义这个运算
3839
+ }
3840
+
3805
3841
  std::string serialise() const
3806
3842
  {
3807
3843
  vec3 eu = coord2eulers();
@@ -3847,134 +3883,7 @@ struct coord3 : vcoord3
3847
3883
  }
3848
3884
  return hash;
3849
3885
  }
3850
-
3851
- // ============================================================================
3852
- // Differential Geometry: Connection Operator (Intrinsic Gradient)
3853
- // ============================================================================
3854
-
3855
- /**
3856
- * Compute metric tensor determinant: det(g) = E*G - F²
3857
- *
3858
- * For a parametric surface, the first fundamental form is:
3859
- * g = [[E, F], [F, G]]
3860
- * where:
3861
- * E = VX · VX (squared length of X-axis basis vector)
3862
- * F = VX · VY (dot product of X and Y basis vectors)
3863
- * G = VY · VY (squared length of Y-axis basis vector)
3864
- *
3865
- * Returns: det(g) = E*G - F²
3866
- */
3867
- real compute_metric_det() const
3868
- {
3869
- vec3 vx = VX();
3870
- vec3 vy = VY();
3871
- real E = vx.dot(vx);
3872
- real F = vx.dot(vy);
3873
- real G = vy.dot(vy);
3874
- return E * G - F * F;
3875
- }
3876
-
3877
- /**
3878
- * Compute base connection operator: G' = (c2*c1^-1)/C2 - I/C1
3879
- *
3880
- * This is the fundamental discrete connection operator formula.
3881
- *
3882
- * Parameters:
3883
- * c1 - coordinate frame at point (u, v)
3884
- * c2 - coordinate frame at point (u+h, v) or (u, v+h)
3885
- * C1 - scale factor at c1 (typically sqrt(det(g1)) or c1.s.mean())
3886
- * C2 - scale factor at c2 (typically sqrt(det(g2)) or c2.s.mean())
3887
- *
3888
- * Returns: G' (base connection operator as coord3)
3889
- *
3890
- * Mathematical interpretation:
3891
- * G' represents the discrete covariant derivative of the frame field.
3892
- * It measures how the coordinate frame changes as we move along the surface.
3893
- */
3894
- static coord3 connection_operator_base(
3895
- const coord3& c1,
3896
- const coord3& c2,
3897
- real C1,
3898
- real C2
3899
- )
3900
- {
3901
- // G' = (c2*c1^-1)/C2 - I/C1
3902
- // where c1^-1 is computed as c2/c1
3903
- coord3 identity; // Identity coordinate frame
3904
- coord3 term1 = (c2 / c1) / C2;
3905
- coord3 term2 = identity / C1;
3906
- return term1 - term2;
3907
- }
3908
-
3909
- /**
3910
- * Compute connection operator with corrections: G = f(G')
3911
- *
3912
- * Applies scale correction and optional metric correction to G'.
3913
- *
3914
- * Parameters:
3915
- * c1, c2 - coordinate frames (see connection_operator_base)
3916
- * C1, C2 - scale factors
3917
- * scale_factor - overall scale multiplier (optimal: 2.0 for spheres)
3918
- * use_metric_correction - if true, applies 1/√det(g) correction
3919
- *
3920
- * Returns: G (corrected connection operator)
3921
- *
3922
- * Formula:
3923
- * If use_metric_correction:
3924
- * G = scale_factor * G' / √det(g)
3925
- * Else:
3926
- * G = scale_factor * G'
3927
- *
3928
- * For constant curvature surfaces (spheres), optimal parameters are:
3929
- * - scale_factor = 2.0
3930
- * - use_metric_correction = true
3931
- * - This achieves ~2.22% accuracy in Gaussian curvature computation
3932
- */
3933
- static coord3 connection_operator(
3934
- const coord3& c1,
3935
- const coord3& c2,
3936
- real C1,
3937
- real C2,
3938
- real scale_factor = 2.0,
3939
- bool use_metric_correction = true
3940
- )
3941
- {
3942
- // Compute base operator
3943
- coord3 G_prime = connection_operator_base(c1, c2, C1, C2);
3944
-
3945
- // Apply scale correction
3946
- coord3 G = G_prime * scale_factor;
3947
-
3948
- // Apply metric correction if requested
3949
- if (use_metric_correction)
3950
- {
3951
- real det_g = c1.compute_metric_det();
3952
- if (det_g > 1e-10)
3953
- {
3954
- real metric_factor = 1.0 / sqrt(det_g);
3955
- G = G * metric_factor;
3956
- }
3957
- }
3958
-
3959
- return G;
3960
- }
3961
-
3962
- /**
3963
- * Compute Lie bracket [G_u, G_v] = G_u * G_v - G_v * G_u
3964
- *
3965
- * The Lie bracket measures the non-commutativity of the connection operators.
3966
- * It appears in the curvature tensor formula as the Lie derivative term.
3967
- *
3968
- * Parameters:
3969
- * G_u - connection operator in u-direction
3970
- * G_v - connection operator in v-direction
3971
- *
3972
- * Returns: [G_u, G_v] = G_u * G_v - G_v * G_u
3973
- */
3974
- static coord3 lie_bracket(const coord3& G_u, const coord3& G_v)
3975
- {
3976
- return G_u * G_v - G_v * G_u;
3977
- }
3886
+
3978
3887
  };
3979
3888
 
3980
3889
  inline const coord3 coord3::ZERO = {ucoord3::ONE, vec3::ZERO, vec3::ZERO };
@@ -2,7 +2,7 @@
2
2
  setup.py - Cross-platform setup for coordinate_system package
3
3
 
4
4
  Author: PanGuoJun
5
- Version: 2.4.0
5
+ Version: 2.4.2
6
6
  License: MIT
7
7
  """
8
8
 
@@ -69,7 +69,7 @@ ext_modules = [
69
69
 
70
70
  setup(
71
71
  name='coordinate_system',
72
- version='2.4.0',
72
+ version='2.4.2',
73
73
  packages=find_packages(),
74
74
  ext_modules=ext_modules, # Add extension modules
75
75