coordinate-system 5.2.2__tar.gz → 6.0.1__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 (29) hide show
  1. coordinate_system-6.0.1/PKG-INFO +721 -0
  2. coordinate_system-6.0.1/README.md +679 -0
  3. coordinate_system-6.0.1/coordinate_system/__init__.py +276 -0
  4. coordinate_system-6.0.1/coordinate_system/differential_geometry.py +986 -0
  5. coordinate_system-6.0.1/coordinate_system/fourier_spectral.py +149 -0
  6. coordinate_system-6.0.1/coordinate_system/frames.py +1571 -0
  7. coordinate_system-6.0.1/coordinate_system/visualization.py +1069 -0
  8. coordinate_system-6.0.1/coordinate_system.egg-info/PKG-INFO +721 -0
  9. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/coordinate_system.egg-info/SOURCES.txt +1 -2
  10. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/setup.py +4 -4
  11. coordinate_system-5.2.2/PKG-INFO +0 -807
  12. coordinate_system-5.2.2/README.md +0 -765
  13. coordinate_system-5.2.2/coordinate_system/__init__.py +0 -301
  14. coordinate_system-5.2.2/coordinate_system/curvature.py +0 -321
  15. coordinate_system-5.2.2/coordinate_system/differential_geometry.py +0 -666
  16. coordinate_system-5.2.2/coordinate_system/fourier_spectral.py +0 -763
  17. coordinate_system-5.2.2/coordinate_system/qframes.py +0 -675
  18. coordinate_system-5.2.2/coordinate_system/visualization.py +0 -666
  19. coordinate_system-5.2.2/coordinate_system.egg-info/PKG-INFO +0 -807
  20. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/LICENSE +0 -0
  21. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/MANIFEST.in +0 -0
  22. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/coordinate_system/curve_interpolation.py +0 -0
  23. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/coordinate_system.egg-info/dependency_links.txt +0 -0
  24. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/coordinate_system.egg-info/not-zip-safe +0 -0
  25. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/coordinate_system.egg-info/requires.txt +0 -0
  26. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/coordinate_system.egg-info/top_level.txt +0 -0
  27. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/coordinate_system_binding.cpp +0 -0
  28. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/pmsys_minimal.hpp +0 -0
  29. {coordinate_system-5.2.2 → coordinate_system-6.0.1}/setup.cfg +0 -0
@@ -0,0 +1,721 @@
1
+ Metadata-Version: 2.1
2
+ Name: coordinate_system
3
+ Version: 6.0.1
4
+ Summary: High-performance 3D coordinate system library with unified differential geometry, quantum frame algebra, spectral transforms, and professional curvature visualization
5
+ Home-page: https://github.com/panguojun/Coordinate-System
6
+ Author: PanGuoJun
7
+ Author-email: 18858146@qq.com
8
+ License: MIT
9
+ Project-URL: Bug Reports, https://github.com/panguojun/Coordinate-System/issues
10
+ Project-URL: Source, https://github.com/panguojun/Coordinate-System
11
+ Project-URL: Documentation, https://github.com/panguojun/Coordinate-System/blob/main/README.md
12
+ Keywords: 3d math vector quaternion coordinate-system geometry graphics spatial-computing differential-geometry curvature curve-interpolation c2-continuity frenet-frames fourier-transform operator-overloading quantum-coordinates heisenberg-uncertainty visualization rgb-frames catmull-rom squad intrinsic-gradient spectral-analysis surface-visualization
13
+ Platform: Windows
14
+ Platform: Linux
15
+ Platform: macOS
16
+ Platform: Android
17
+ Platform: iOS
18
+ Classifier: Development Status :: 5 - Production/Stable
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Intended Audience :: Science/Research
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
23
+ Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
24
+ Classifier: License :: OSI Approved :: MIT License
25
+ Classifier: Programming Language :: Python :: 3
26
+ Classifier: Programming Language :: Python :: 3.7
27
+ Classifier: Programming Language :: Python :: 3.8
28
+ Classifier: Programming Language :: Python :: 3.9
29
+ Classifier: Programming Language :: Python :: 3.10
30
+ Classifier: Programming Language :: Python :: 3.11
31
+ Classifier: Programming Language :: Python :: 3.12
32
+ Classifier: Programming Language :: Python :: 3.13
33
+ Classifier: Programming Language :: C++
34
+ Classifier: Operating System :: Microsoft :: Windows
35
+ Classifier: Operating System :: POSIX :: Linux
36
+ Classifier: Operating System :: MacOS
37
+ Requires-Python: >=3.7
38
+ Description-Content-Type: text/markdown
39
+ License-File: LICENSE
40
+ Requires-Dist: numpy>=1.19.0
41
+ Requires-Dist: matplotlib>=3.3.0
42
+
43
+ # Coordinate System Library
44
+
45
+ **High-performance 3D coordinate system and differential geometry library for Python**
46
+
47
+ [![PyPI version](https://badge.fury.io/py/coordinate-system.svg)](https://pypi.org/project/coordinate-system/)
48
+ [![Python](https://img.shields.io/pypi/pyversions/coordinate-system.svg)](https://pypi.org/project/coordinate-system/)
49
+ [![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-blue.svg)](https://pypi.org/project/coordinate-system/)
50
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
51
+
52
+ **Author:** PanGuoJun
53
+ **Version:** 6.0.1
54
+ **License:** MIT
55
+
56
+ ---
57
+
58
+ ## 🆕 What's New in v6.0.1 (2025-12-04)
59
+
60
+ ### Classical Spectral Geometry Implementation
61
+
62
+ **ComplexFrame-Based Spectral Geometry** - Complete implementation of **classical geometric spectral analysis** using ComplexFrame as the mathematical foundation
63
+
64
+ > **Important Design Philosophy**:
65
+ >
66
+ > This library follows the progression: **Coordinate System (Geometric Frame) → Curvature Computation → ComplexFrame → Spectral Geometry**
67
+ >
68
+ > All implementations are **classical geometric tools** suitable for numerical computation on standard computers. While the mathematical formalism resembles quantum theory, this is purely **classical differential geometry** without quantum physical interpretation.
69
+
70
+ #### 🎯 **Core Class Renaming (Breaking Change)**
71
+ - **QFrame → ComplexFrame**: More descriptive name avoiding confusion with generic "Frame"
72
+ - **QFrameSpectrum → ComplexFrameSpectrum**: Consistent naming convention
73
+ - **Backward Compatibility**: All old names (QFrame, QFrameSpectrum) retained as aliases
74
+
75
+ #### 🌟 **ComplexFrame as Mathematical Foundation**
76
+
77
+ **ComplexFrame represents the mathematical language for all spectral geometry formulas:**
78
+
79
+ **1. ComplexFrame Algebra (复标架代数)**
80
+ ```python
81
+ # Core transformations
82
+ ComplexFrame * e^{iθ} # Fourier transform (phase rotation)
83
+ ComplexFrame * λ # Conformal transform (scaling)
84
+ e^{tΔ} ComplexFrame # Diffusion evolution (heat equation solution)
85
+ ```
86
+ - Complex extension of coordinate frames: ComplexFrame = coord3 ⊗ ℂ
87
+ - Mathematical tool for spectral analysis (not quantum states)
88
+ - Laplacian operator: Δ log ComplexFrame
89
+
90
+ **2. IntrinsicGradient (内禀梯度算子)**
91
+ ```python
92
+ G_μ = d/dx^μ log ComplexFrame(x)
93
+ ```
94
+ - **Geometric meaning**: Local frame rotation rate (covariant derivative)
95
+ - Corresponds to connection 1-form in Riemannian geometry
96
+ - Computes curvature via Lie bracket: R_{μν} = [G_μ, G_ν]
97
+ - **Classical object**: No quantum interpretation needed
98
+
99
+ **3. HeatKernel (热核 - Heat Equation Solution)**
100
+ ```python
101
+ ∂u/∂t = Δu (Classical heat equation)
102
+ Tr(e^{tΔ}) ~ (4πt)^{-d/2} [a₀ + a₁t + a₂t² + ...]
103
+ ```
104
+ - **ComplexFrame evolution**: ComplexFrame(x,t) = e^{tΔ} ComplexFrame(x,0)
105
+ - **Classical diffusion process** (NOT quantum imaginary time)
106
+ - Heat kernel coefficients encode geometric invariants:
107
+ - a₀ = Volume of manifold
108
+ - a₁ ∝ ∫ Scalar curvature
109
+ - a₂ ∝ ∫ (R² + higher curvature terms)
110
+ - **Application**: ShapeDNA, spectral distances, multi-scale analysis
111
+
112
+ **4. SpectralDecomposition (谱分解)**
113
+ ```python
114
+ Δφ_n = -λ_n φ_n (Laplacian eigenvalue problem)
115
+ ComplexFrame(x) = Σ_n c_n φ_n(x) ComplexFrame_n
116
+ ```
117
+ - **ComplexFrame as eigenstates**: Expansion in Laplacian eigenbasis
118
+ - **Shape DNA**: Eigenvalue spectrum {λ_n} characterizes manifold geometry
119
+ - Weyl asymptotic law: N(λ) ~ (1/4π) Area(M) λ (2D case)
120
+ - **Classical spectral theory**: "Can one hear the shape of a drum?" (Kac, 1966)
121
+
122
+ **5. BerryPhase (几何相位)**
123
+ ```python
124
+ γ = ∮_C G_μ dx^μ
125
+ ```
126
+ - **Classical geometric phase**: Parallel transport in frame bundle
127
+ - **NOT quantum Berry phase** (though mathematically analogous)
128
+ - Path-independent topological quantity
129
+ - Related to Chern number via Stokes theorem
130
+
131
+ **6. ChernNumber (陈数)**
132
+ ```python
133
+ c₁ = (1/2π) ∬_M R_{μν} dS
134
+ ```
135
+ - **Topological invariant** of fiber bundle
136
+ - Integer-valued geometric index
137
+ - Characterizes global geometry of ComplexFrame field
138
+ - **Classical topology**: No quantum Hall effect interpretation here
139
+
140
+ **7. CurvatureFromFrame (曲率计算)**
141
+ ```python
142
+ R_{μν} = [G_μ, G_ν]
143
+ K = -Im(R_{xy}) (Gaussian curvature, for complex frames)
144
+ ```
145
+ - Curvature computed from ComplexFrame field
146
+ - Intrinsic gradient formulation
147
+ - **Classical differential geometry**
148
+
149
+ #### 📐 **Mathematical Framework (Classical)**
150
+
151
+ **Based on:**
152
+ - Differential geometry (Riemannian manifolds, curvature)
153
+ - Spectral theory (Laplacian eigenvalue problems)
154
+ - Fiber bundle theory (frame bundles, connections)
155
+ - Lie algebra (commutators, curvature 2-forms)
156
+
157
+ **Theoretical Limitations:**
158
+ - ⚠️ **Classical only**: No quantum superposition, entanglement, or measurement
159
+ - ⚠️ **Computational**: Requires discretization (finite difference, spectral methods)
160
+ - ⚠️ **Not quantum computing**: All operations run on classical computers
161
+ - ⚠️ Forms **resemble** quantum theory but physical interpretation is purely geometric
162
+
163
+ #### 🔬 **Core Formulas Summary**
164
+ ```
165
+ ComplexFrame = coord3 ⊗ ℂ [Mathematical Foundation]
166
+ G_μ = d/dx^μ log ComplexFrame(x) [Intrinsic Gradient]
167
+ R_{μν} = [G_μ, G_ν] [Curvature]
168
+ Δ log ComplexFrame = ∂²/∂x² + ∂²/∂y² [Laplacian]
169
+ e^{tΔ} ComplexFrame = Heat diffusion evolution [Heat Kernel]
170
+ Δφ_n = -λ_n φ_n [Spectral Decomposition]
171
+ ComplexFrame = Σ_n c_n φ_n ComplexFrame_n [Eigenbasis Expansion]
172
+ γ = ∮ G_μ dx^μ [Geometric Phase]
173
+ c₁ = (1/2π) ∬ R_{μν} dS [Chern Number]
174
+ ```
175
+
176
+ ### Breaking Changes
177
+
178
+ - `QFrame` → `ComplexFrame` (old name works as alias)
179
+ - `QFrameSpectrum` → `ComplexFrameSpectrum` (old name works as alias)
180
+ - `qframes.py` deleted (functionality moved to `frames.py`)
181
+ - Quantum-related classes removed (QuantumState, PathIntegral, Dirac notation)
182
+
183
+ ### Migration Guide
184
+
185
+ ```python
186
+ # Old code (still works with aliases):
187
+ from coordinate_system import QFrame, QFrameSpectrum
188
+
189
+ # New code (recommended):
190
+ from coordinate_system import ComplexFrame, ComplexFrameSpectrum
191
+
192
+ # Full classical spectral geometry toolkit:
193
+ from coordinate_system import (
194
+ ComplexFrame, ComplexFrameSpectrum,
195
+ IntrinsicGradient, CurvatureFromFrame,
196
+ BerryPhase, ChernNumber,
197
+ SpectralDecomposition, HeatKernel,
198
+ FrequencyProjection, FrequencyBandState,
199
+ )
200
+ ```
201
+
202
+ **Example: Heat Kernel Diffusion**
203
+ ```python
204
+ from coordinate_system import ComplexFrame, HeatKernel
205
+
206
+ # Create a ComplexFrame field
207
+ frame_field = [[ComplexFrame(q_factor=1.0 + 0.1j*(i+j))
208
+ for j in range(10)] for i in range(10)]
209
+
210
+ # Initialize heat kernel
211
+ heat = HeatKernel(frame_field)
212
+
213
+ # Evolve using classical diffusion (NOT quantum evolution)
214
+ t = 0.1 # Diffusion time
215
+ evolved_field = heat.evolution_operator(t, kappa=1.0)
216
+
217
+ # Compute heat kernel trace (geometric invariant)
218
+ trace = heat.trace(t)
219
+
220
+ # Asymptotic expansion (extracts curvature information)
221
+ asymptotic = heat.asymptotic_expansion(t, order=2)
222
+ ```
223
+
224
+ ---
225
+
226
+ ## 🆕 What's New in v6.0.0 (2025-12-03)
227
+
228
+ ### Major Architecture Refactoring
229
+
230
+ **Unified Differential Geometry Module** - Complete integration of curvature computation methods
231
+
232
+ - **Merged Module**: `differential_geometry.py` now contains both classical and intrinsic gradient methods
233
+ - **Dual Method Support**:
234
+ - Intrinsic gradient method (default): `compute_gaussian_curvature()`, `compute_mean_curvature()`
235
+ - Classical method: `gaussian_curvature_classical()`, `mean_curvature_classical()`
236
+ - **Backward Compatibility**: Old function names still work as aliases
237
+ - **High-Order Finite Differences**: 5-point formulas with O(h⁴) accuracy
238
+ - **All English Documentation**: Complete internationalization for global distribution
239
+
240
+ **Enhanced Visualization Module** - Professional surface and curvature rendering
241
+
242
+ - **New Class**: `SurfaceVisualizer` with curvature coloring support
243
+ - **Curvature Visualization**: Diverging colormap (blue-white-red) for Gaussian/Mean curvature
244
+ - **Surface Frame Fields**: RGB-coded tangent frames (red=u direction, green=v direction, blue=normal)
245
+ - **Enhanced Curve Rendering**: Binormal support, improved styling
246
+ - **Integration**: Direct support for differential_geometry surfaces
247
+ - **Convenience Functions**: `visualize_surface()` for quick visualization
248
+
249
+ **Runtime Handedness Switching** - Flexible coordinate system control
250
+
251
+ - **Global Control**: Switch between left-handed and right-handed systems at runtime
252
+ - **API Functions**: `set_handedness('left'/'right')`, `get_handedness()`, `is_left_handed()`
253
+ - **Automatic Adaptation**: All vector operations, quaternions, and Frenet frames adjust automatically
254
+ - **Cross-Platform Compatibility**: Seamlessly work with DirectX (left-handed) and OpenGL (right-handed) conventions
255
+
256
+ ---
257
+
258
+ ## Features
259
+
260
+ ### Core Components
261
+
262
+ **C++ Performance Layer:**
263
+ - **vec3** - 3D vector with comprehensive operations
264
+ - **vec2** - 2D vector for parametric coordinates
265
+ - **quat** - Quaternion for 3D rotations
266
+ - **coord3** - Complete 3D coordinate system (position, rotation, scale)
267
+
268
+ **Advanced Mathematics Modules:**
269
+ - **differential_geometry** - Surface analysis with dual curvature methods
270
+ - **frames** - Complex frame algebra with spectral geometry
271
+ - **visualization** - Professional 3D rendering for geometry and curvature
272
+ - **curve_interpolation** - C2-continuous curve and frame interpolation
273
+
274
+ ### Operations
275
+
276
+ - Vector arithmetic (+, -, *, /)
277
+ - Dot product, cross product (runtime switchable handedness)
278
+ - Vector projection, reflection
279
+ - Linear interpolation (lerp)
280
+ - Spherical linear interpolation (slerp)
281
+ - Coordinate system transformations
282
+ - Euler angle conversion
283
+ - Gaussian and mean curvature computation
284
+ - Spectral analysis and Fourier transforms
285
+ - **Runtime handedness control** (left/right-handed systems)
286
+ - **Spectral geometry analysis** (Berry phase, Chern number, heat kernel)
287
+
288
+ ### Performance
289
+
290
+ - Written in optimized C++17
291
+ - Python bindings via pybind11
292
+ - Over 1,000,000 operations per second
293
+ - GPU acceleration for spectral transforms (optional)
294
+
295
+ ### Platform Support
296
+
297
+ - ✅ Windows (7, 10, 11)
298
+ - ✅ Linux (Ubuntu, Debian, CentOS, etc.)
299
+ - ✅ macOS (10.14+)
300
+
301
+ ---
302
+
303
+ ## 📚 Documentation
304
+
305
+ ### Mathematical Foundation
306
+
307
+ For a comprehensive understanding of the mathematical principles behind coordinate systems, vectors, quaternions, and differential geometry, see our detailed guide:
308
+
309
+ **[📖 Mathematical Foundation of Coordinate Systems](https://github.com/panguojun/Coordinate-System)**
310
+
311
+ ### Module Documentation
312
+
313
+ - [Curve Interpolation Guide](CURVE_INTERPOLATION_README.md)
314
+ - [C2 Interpolation Guide](C2_INTERPOLATION_GUIDE.md)
315
+
316
+ ---
317
+
318
+ ## Installation
319
+
320
+ ### From PyPI (Recommended)
321
+
322
+ ```bash
323
+ pip install coordinate-system
324
+ ```
325
+
326
+ ### From Source
327
+
328
+ ```bash
329
+ git clone https://github.com/panguojun/Coordinate-System.git
330
+ cd Coordinate-System
331
+ pip install .
332
+ ```
333
+
334
+ ---
335
+
336
+ ## Quick Start
337
+
338
+ ```python
339
+ from coordinate_system import vec3, quat, coord3
340
+
341
+ # Create vectors
342
+ v1 = vec3(1, 2, 3)
343
+ v2 = vec3(4, 5, 6)
344
+
345
+ # Vector operations
346
+ v3 = v1 + v2 # Addition: vec3(5, 7, 9)
347
+ dot = v1.dot(v2) # Dot product: 32.0
348
+ cross = v1.cross(v2) # Cross product (left-handed)
349
+ length = v1.length() # Length: 3.742
350
+ normalized = v1.normcopy() # Unit vector
351
+
352
+ # Quaternion rotation
353
+ axis = vec3(0, 0, 1) # Z axis
354
+ q = quat(1.5708, axis) # 90 degrees rotation
355
+ rotated = q * v1 # Rotate v1
356
+
357
+ # Coordinate systems
358
+ frame = coord3.from_angle(1.57, vec3(0, 0, 1)) # Frame rotated 90°
359
+ world_pos = v1 * frame # Transform to world space
360
+ local_pos = world_pos / frame # Transform back to local
361
+
362
+ # Differential geometry
363
+ from coordinate_system import Sphere, compute_gaussian_curvature
364
+
365
+ sphere = Sphere(radius=1.0)
366
+ K = compute_gaussian_curvature(sphere, u=0.5, v=0.5) # K = 1.0 for unit sphere
367
+
368
+ # Visualization
369
+ from coordinate_system import visualize_surface
370
+
371
+ visualize_surface(sphere, curvature_type='gaussian', show_colorbar=True)
372
+
373
+ # Spectral geometry (NEW in 6.0.1)
374
+ from coordinate_system import (
375
+ ComplexFrame, IntrinsicGradient,
376
+ CurvatureFromFrame, BerryPhase
377
+ )
378
+
379
+ # Create frame field
380
+ frame_field = [[ComplexFrame(q_factor=1.0 + 0.1j*(i+j))
381
+ for j in range(10)] for i in range(10)]
382
+
383
+ # Compute intrinsic gradient
384
+ grad_op = IntrinsicGradient(frame_field)
385
+ G_x = grad_op.compute_at((5, 5), 0) # ∂_x log ComplexFrame
386
+
387
+ # Compute curvature
388
+ curv_calc = CurvatureFromFrame(frame_field)
389
+ K = curv_calc.gaussian_curvature(5, 5)
390
+
391
+ # Compute Berry phase
392
+ berry = BerryPhase(grad_op)
393
+ path = [(1, 1), (1, 8), (8, 8), (8, 1), (1, 1)]
394
+ gamma = berry.compute_along_path(path) # γ = ∮ G_μ dx^μ
395
+ ```
396
+
397
+ ---
398
+
399
+ ## Module Guide
400
+
401
+ ### Complex Frame Module (NEW in 6.0.1)
402
+
403
+ ```python
404
+ from coordinate_system import (
405
+ # Core classes
406
+ ComplexFrame, QuantumState, PathIntegral, ComplexFrameSpectrum,
407
+
408
+ # Spectral geometry core
409
+ IntrinsicGradient, CurvatureFromFrame,
410
+ BerryPhase, ChernNumber,
411
+ SpectralDecomposition, HeatKernel,
412
+ FrequencyProjection, FrequencyBandState,
413
+
414
+ # Dirac notation (optional export)
415
+ DiracBra, DiracKet, bra, ket,
416
+
417
+ # Spectral transforms
418
+ spectral_transform, inverse_spectral_transform,
419
+
420
+ # Constants
421
+ HBAR, GPU_AVAILABLE,
422
+ )
423
+
424
+ # Create complex frame
425
+ cf = ComplexFrame(base_coord=coord3(), q_factor=1.0+0.5j)
426
+
427
+ # Fourier transform (phase rotation)
428
+ cf_ft = cf.fourier_transform(theta=np.pi/2) # ComplexFrame * e^{iθ}
429
+
430
+ # Conformal transform (scaling)
431
+ cf_conf = cf.conformal_transform(2.0) # ComplexFrame * λ
432
+
433
+ # Intrinsic gradient operator
434
+ frame_field = [[ComplexFrame(q_factor=1.0 + 0.1j*(i+j))
435
+ for j in range(16)] for i in range(16)]
436
+ grad_op = IntrinsicGradient(frame_field)
437
+ G_x = grad_op.compute_at((8, 8), 0) # G_x = ∂_x log ComplexFrame
438
+ G_y = grad_op.compute_at((8, 8), 1) # G_y = ∂_y log ComplexFrame
439
+
440
+ # Curvature from frame field
441
+ curv_calc = CurvatureFromFrame(frame_field)
442
+ K = curv_calc.gaussian_curvature(8, 8) # Gaussian curvature
443
+ H = curv_calc.mean_curvature(8, 8) # Mean curvature
444
+
445
+ # Berry phase
446
+ berry = BerryPhase(grad_op)
447
+ path = [(4, 4), (4, 12), (12, 12), (12, 4), (4, 4)]
448
+ gamma = berry.compute_along_path(path, closed=True) # γ = ∮ G_μ dx^μ
449
+
450
+ # Chern number (topological invariant)
451
+ chern = ChernNumber(curv_calc)
452
+ c1 = chern.compute() # c₁ = (1/2π) ∬ R_{μν} dS
453
+
454
+ # Spectral decomposition
455
+ # First create a ComplexFrameSpectrum from coordinate field
456
+ import numpy as np
457
+ coord_field = [[coord3(vec3(i, j, 0)) for j in range(16)] for i in range(16)]
458
+ spectrum = spectral_transform(coord_field)
459
+
460
+ decomp = SpectralDecomposition(spectrum)
461
+ eigenvalues, _ = decomp.compute_eigenspectrum()
462
+ shape_dna = decomp.shape_dna(n_modes=50) # First 50 eigenvalues
463
+
464
+ # Heat kernel
465
+ heat = HeatKernel(decomp)
466
+ trace_t = heat.trace(t=0.1) # Tr(e^{-tK̂})
467
+ asymp = heat.asymptotic_expansion(t=0.1, order=3)
468
+
469
+ # Frequency projection
470
+ freq_proj = FrequencyProjection(decomp)
471
+ frequencies = freq_proj.compute_frequencies() # ω_n = √|κ_n| · sign(κ_n)
472
+ band_state = freq_proj.project_to_band(omega_min=0.5, omega_max=2.0)
473
+ ```
474
+
475
+ ### Differential Geometry Module
476
+
477
+ ```python
478
+ from coordinate_system import (
479
+ # Surface classes
480
+ Surface, Sphere, Torus,
481
+
482
+ # Intrinsic gradient method (default, more accurate)
483
+ compute_gaussian_curvature,
484
+ compute_mean_curvature,
485
+ compute_riemann_curvature,
486
+ compute_all_curvatures,
487
+
488
+ # Classical method (high-order finite differences)
489
+ gaussian_curvature_classical,
490
+ mean_curvature_classical,
491
+ principal_curvatures_classical,
492
+
493
+ # Method comparison
494
+ compare_methods,
495
+ )
496
+
497
+ # Create a surface
498
+ sphere = Sphere(radius=2.0)
499
+ torus = Torus(major_radius=3.0, minor_radius=1.0)
500
+
501
+ # Compute curvature (intrinsic gradient method)
502
+ K = compute_gaussian_curvature(sphere, u=0.5, v=0.5)
503
+ H = compute_mean_curvature(sphere, u=0.5, v=0.5)
504
+
505
+ # Use classical method
506
+ K_classical = gaussian_curvature_classical(sphere, u=0.5, v=0.5)
507
+
508
+ # Compare methods
509
+ results = compare_methods(sphere, u=0.5, v=0.5)
510
+ print(f"Intrinsic: K={results['intrinsic']['K']:.6f}")
511
+ print(f"Classical: K={results['classical']['K']:.6f}")
512
+ ```
513
+
514
+ ### Visualization Module
515
+
516
+ ```python
517
+ from coordinate_system import (
518
+ CoordinateSystemVisualizer,
519
+ CurveVisualizer,
520
+ SurfaceVisualizer,
521
+ visualize_coord_system,
522
+ visualize_curve,
523
+ visualize_surface,
524
+ )
525
+
526
+ # Quick surface visualization with curvature
527
+ from coordinate_system import Sphere
528
+
529
+ sphere = Sphere(radius=1.0)
530
+ visualize_surface(
531
+ sphere,
532
+ curvature_type='gaussian', # or 'mean'
533
+ show_colorbar=True,
534
+ show_normals=False,
535
+ show_frames=True,
536
+ title='Sphere with Gaussian Curvature'
537
+ )
538
+ ```
539
+
540
+ ---
541
+
542
+ ## Advanced Examples
543
+
544
+ ### Spectral Geometry Analysis (NEW)
545
+
546
+ ```python
547
+ from coordinate_system import (
548
+ ComplexFrame, IntrinsicGradient,
549
+ CurvatureFromFrame, BerryPhase, ChernNumber,
550
+ SpectralDecomposition, spectral_transform
551
+ )
552
+ import numpy as np
553
+
554
+ # Create a complex frame field (wave-like pattern)
555
+ nx, ny = 32, 32
556
+ frame_field = []
557
+ for i in range(ny):
558
+ row = []
559
+ for j in range(nx):
560
+ phase = 2*np.pi*(i/ny + j/nx)
561
+ amplitude = 1.0 + 0.3*np.sin(2*np.pi*i/ny)*np.cos(2*np.pi*j/nx)
562
+ q = amplitude * np.exp(1j * phase)
563
+ row.append(ComplexFrame(q_factor=q))
564
+ frame_field.append(row)
565
+
566
+ # 1. Intrinsic gradient
567
+ grad_op = IntrinsicGradient(frame_field)
568
+ print("=== Intrinsic Gradient ===")
569
+ for i in range(5, 28, 8):
570
+ for j in range(5, 28, 8):
571
+ G_x = grad_op.compute_at((i, j), 0)
572
+ G_y = grad_op.compute_at((i, j), 1)
573
+ print(f" ({i},{j}): G_x={G_x:.4f}, G_y={G_y:.4f}")
574
+
575
+ # 2. Curvature
576
+ curv_calc = CurvatureFromFrame(frame_field)
577
+ print("\n=== Curvature ===")
578
+ K_values = []
579
+ for i in range(5, 28, 4):
580
+ for j in range(5, 28, 4):
581
+ K = curv_calc.gaussian_curvature(i, j)
582
+ K_values.append(K)
583
+ if abs(K) > 0.01:
584
+ print(f" ({i},{j}): K={K:.6f}")
585
+ print(f" Average |K|: {np.mean(np.abs(K_values)):.6f}")
586
+
587
+ # 3. Berry phase
588
+ berry = BerryPhase(grad_op)
589
+ print("\n=== Berry Phase ===")
590
+ # Square path
591
+ path_square = [(8, 8), (8, 24), (24, 24), (24, 8), (8, 8)]
592
+ gamma_square = berry.compute_along_path(path_square, closed=True)
593
+ print(f" Square path: γ = {gamma_square:.6f}")
594
+
595
+ # Circular path
596
+ path_circle = []
597
+ for theta in np.linspace(0, 2*np.pi, 32):
598
+ i = int(16 + 8*np.cos(theta))
599
+ j = int(16 + 8*np.sin(theta))
600
+ path_circle.append((i, j))
601
+ gamma_circle = berry.compute_along_path(path_circle, closed=True)
602
+ print(f" Circular path: γ = {gamma_circle:.6f}")
603
+
604
+ # 4. Chern number
605
+ chern = ChernNumber(curv_calc)
606
+ c1 = chern.compute()
607
+ print(f"\n=== Topological Invariant ===")
608
+ print(f" First Chern number: c₁ = {c1}")
609
+
610
+ # 5. Spectral decomposition
611
+ coord_field = [[coord3(vec3(j, i, np.sin(2*np.pi*j/nx)*np.cos(2*np.pi*i/ny)))
612
+ for j in range(nx)] for i in range(ny)]
613
+ spectrum = spectral_transform(coord_field)
614
+ decomp = SpectralDecomposition(spectrum)
615
+ eigenvalues, _ = decomp.compute_eigenspectrum()
616
+
617
+ print(f"\n=== Spectral Decomposition ===")
618
+ print(f" Total modes: {len(eigenvalues)}")
619
+ print(f" Top 10 eigenvalues:")
620
+ for i, ev in enumerate(eigenvalues[:10]):
621
+ print(f" λ_{i} = {ev:.6f}")
622
+
623
+ # Shape DNA
624
+ shape_dna = decomp.shape_dna(n_modes=50)
625
+ print(f" Shape DNA (first 5): {shape_dna[:5]}")
626
+
627
+ # Weyl counting
628
+ n_below_1 = decomp.weyl_counting(kappa=1.0)
629
+ print(f" Eigenvalues < 1.0: {n_below_1}")
630
+
631
+ print("\n" + "="*60)
632
+ print("Spectral Geometry Analysis Complete!")
633
+ print("="*60)
634
+ ```
635
+
636
+ ---
637
+
638
+ ## Performance
639
+
640
+ Benchmark on Intel i7-10700K @ 3.8GHz:
641
+
642
+ | Operation | Ops/second | Notes |
643
+ |-----------|-----------|-------|
644
+ | Vector addition | 5,200,000 | C++ optimized |
645
+ | Dot product | 4,800,000 | C++ optimized |
646
+ | Cross product | 3,500,000 | C++ optimized |
647
+ | Normalize | 2,100,000 | C++ optimized |
648
+ | Quaternion rotation | 1,800,000 | C++ optimized |
649
+ | Gaussian curvature | 85,000 | Python + NumPy |
650
+ | Spectral transform (CPU) | 1,200/sec | 64×64 field |
651
+ | Spectral transform (GPU) | 12,000/sec | 64×64 field, CuPy |
652
+ | Intrinsic gradient | 180,000 | Python + NumPy |
653
+ | Berry phase (path) | 25,000 | Python |
654
+
655
+ ---
656
+
657
+ ## Changelog
658
+
659
+ ### Version 6.0.1 (2025-12-04)
660
+ - 🎯 **COMPLETE SPECTRAL GEOMETRY**: Full implementation of quantum spectral geometry framework
661
+ - ✨ **ComplexFrame Renaming**: QFrame → ComplexFrame (clearer naming)
662
+ - 🌟 **IntrinsicGradient**: G_μ = d/dx^μ log ComplexFrame(x)
663
+ - 🌟 **CurvatureFromFrame**: R_{μν} = [G_μ, G_ν]
664
+ - 🌟 **BerryPhase**: γ = ∮ G_μ dx^μ (geometric phase)
665
+ - 🌟 **ChernNumber**: c₁ = (1/2π) ∬ R_{μν} dS (topological invariant)
666
+ - 🌟 **SpectralDecomposition**: Eigenvalue decomposition, Shape DNA
667
+ - 🌟 **HeatKernel**: Tr(e^{-tK̂}) with asymptotic expansion
668
+ - 🌟 **FrequencyProjection**: Geometric frequency space and band projection
669
+ - 📐 **Mathematical Rigor**: Fiber bundle, Lie algebra, spectral geometry
670
+ - 🔬 **Complete Theory**: Based on unified quantum spectral geometry document
671
+ - 🗑️ **Cleanup**: Removed obsolete qframes.py file
672
+
673
+ ### Version 6.0.0 (2025-12-03)
674
+ - 🔄 **MAJOR REFACTORING**: Unified module architecture
675
+ - ✨ **Merged differential_geometry**: Combined curvature.py functionality with dual-method support
676
+ - ✨ **Merged frames**: Integrated quantum frame modules into unified framework
677
+ - ✨ **Enhanced visualization**: Added SurfaceVisualizer with curvature coloring
678
+ - 🔀 **Runtime handedness control**: Switch between left/right-handed systems on the fly
679
+ - 📚 **Full English documentation**: Complete internationalization
680
+ - ⚡ **Improved API**: Cleaner imports and more intuitive method names
681
+
682
+ ---
683
+
684
+ ## License
685
+
686
+ MIT License - see [LICENSE](LICENSE) file for details
687
+
688
+ Copyright (c) 2024-2025 PanGuoJun
689
+
690
+ ---
691
+
692
+ ## Author
693
+
694
+ **PanGuoJun** (romeosoft)
695
+
696
+ - Email: 18858146@qq.com
697
+ - GitHub: [panguojun/Coordinate-System](https://github.com/panguojun/Coordinate-System)
698
+
699
+ ---
700
+
701
+ ## Links
702
+
703
+ - **PyPI**: https://pypi.org/project/coordinate-system/
704
+ - **GitHub**: https://github.com/panguojun/Coordinate-System
705
+ - **Mathematical Foundation**: [MATHEMATICAL_FOUNDATION.md](https://github.com/panguojun/Coordinate-System/blob/main/MATHEMATICAL_FOUNDATION.md)
706
+ - **Issues**: https://github.com/panguojun/Coordinate-System/issues
707
+
708
+ ---
709
+
710
+ ## Acknowledgments
711
+
712
+ Built with ❤️ using:
713
+ - **C++17** - High-performance core
714
+ - **pybind11** - Python-C++ bindings
715
+ - **NumPy** - Numerical computations
716
+ - **Matplotlib** - Visualization
717
+ - **CuPy** - Optional GPU acceleration
718
+
719
+ ---
720
+
721
+ **Note**: For the latest updates and documentation, visit the [GitHub repository](https://github.com/panguojun/Coordinate-System).