coordinate-system 2.5.7__cp313-cp313-win_amd64.whl → 3.0.0__cp313-cp313-win_amd64.whl

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.
@@ -18,6 +18,7 @@ from .differential_geometry import (
18
18
  compute_intrinsic_gradient,
19
19
  compute_gaussian_curvature,
20
20
  compute_mean_curvature,
21
+ compute_riemann_curvature,
21
22
  compute_all_curvatures,
22
23
  )
23
24
 
@@ -43,10 +44,22 @@ from .curvature import (
43
44
  richardson_extrapolation,
44
45
  )
45
46
 
47
+ # Riemann curvature module (v3.4.0+)
48
+ from .riemann_curvature import (
49
+ # Classes
50
+ RiemannCurvatureCalculator,
51
+
52
+ # Main functions (renamed to avoid conflicts)
53
+ compute_riemann_curvature as compute_riemann_curvature_func,
54
+ compute_gaussian_curvature_riemann,
55
+ compute_full_riemann_tensor,
56
+ verify_riemann_properties,
57
+ )
58
+
46
59
  __all__ = [
47
60
  # Constants
48
61
  'ZERO3','UNITX','UNITY','UNITZ','ONE3','ONE4','ONEC',
49
-
62
+
50
63
  # Core types
51
64
  'vec3', 'vec2', 'quat', 'coord3', 'lerp',
52
65
 
@@ -58,6 +71,7 @@ __all__ = [
58
71
  'compute_intrinsic_gradient',
59
72
  'compute_gaussian_curvature',
60
73
  'compute_mean_curvature',
74
+ 'compute_riemann_curvature',
61
75
  'compute_all_curvatures',
62
76
 
63
77
  # High-precision curvature module - Classical method (v2.3.0+)
@@ -72,6 +86,13 @@ __all__ = [
72
86
  'intrinsic_gradient_all_curvatures',
73
87
  'compare_methods',
74
88
 
89
+ # Riemann curvature module (v3.4.0+)
90
+ 'RiemannCurvatureCalculator',
91
+ 'compute_riemann_curvature_func',
92
+ 'compute_gaussian_curvature_riemann',
93
+ 'compute_full_riemann_tensor',
94
+ 'verify_riemann_properties',
95
+
75
96
  # Utility functions
76
97
  'derivative_5pt', 'derivative_2nd_5pt', 'richardson_extrapolation',
77
98
  ]
@@ -357,6 +357,103 @@ class IntrinsicGradientCurvatureCalculator:
357
357
 
358
358
  return K
359
359
 
360
+ def compute_riemann_curvature(self, u: float, v: float, proportional_correction: bool = True) -> float:
361
+ """
362
+ Compute Riemann curvature tensor component R^1_212
363
+ Based on the intrinsic gradient operator method with correct implementation
364
+ """
365
+ delta = self.h
366
+
367
+ # 计算中心标架
368
+ c_center = self.grad_op.calc_intrinsic_frame(u, v)
369
+
370
+ # 计算u方向的内禀梯度算子(使用中心差分)
371
+ c_u_plus = self.grad_op.calc_intrinsic_frame(u + delta, v)
372
+ c_u_minus = self.grad_op.calc_intrinsic_frame(u - delta, v)
373
+ G_u = (c_u_plus - c_u_minus) / (2 * delta)
374
+
375
+ # 计算v方向的内禀梯度算子(使用中心差分)
376
+ c_v_plus = self.grad_op.calc_intrinsic_frame(u, v + delta)
377
+ c_v_minus = self.grad_op.calc_intrinsic_frame(u, v - delta)
378
+ G_v = (c_v_plus - c_v_minus) / (2 * delta)
379
+
380
+ # 计算李括号 [G_u, G_v] = G_u ∘ G_v - G_v ∘ G_u
381
+ # 这需要计算二阶混合偏导数
382
+
383
+ # 计算 ∂²c/∂u∂v 和 ∂²c/∂v∂u
384
+ c_uv_pp = self.grad_op.calc_intrinsic_frame(u + delta, v + delta)
385
+ c_uv_pm = self.grad_op.calc_intrinsic_frame(u + delta, v - delta)
386
+ c_uv_mp = self.grad_op.calc_intrinsic_frame(u - delta, v + delta)
387
+ c_uv_mm = self.grad_op.calc_intrinsic_frame(u - delta, v - delta)
388
+
389
+ # 二阶混合偏导数 ∂²c/∂u∂v
390
+ d2c_dudv = (c_uv_pp - c_uv_pm - c_uv_mp + c_uv_mm) / (4 * delta * delta)
391
+
392
+ # 对于对称的联络,∂²c/∂v∂u = ∂²c/∂u∂v,所以李括号简化为零
393
+ # 但是我们需要考虑标架的非对易性
394
+
395
+ # 更精确的方法:直接计算联络系数的变化
396
+ # 提取法向量的导数(这是关键)
397
+ dn_du = G_u.VZ() # 法向量在u方向的导数
398
+ dn_dv = G_v.VZ() # 法向量在v方向的导数
399
+
400
+ # 计算切向量(根据曲面类型)
401
+ if isinstance(self.surface, Sphere):
402
+ R = self.surface.R
403
+ theta, phi = u, v
404
+ r_u = vec3(
405
+ R * math.cos(theta) * math.cos(phi),
406
+ R * math.cos(theta) * math.sin(phi),
407
+ -R * math.sin(theta)
408
+ )
409
+ r_v = vec3(
410
+ -R * math.sin(theta) * math.sin(phi),
411
+ R * math.sin(theta) * math.cos(phi),
412
+ 0
413
+ )
414
+ elif isinstance(self.surface, Torus):
415
+ R = self.surface.R
416
+ r = self.surface.r
417
+ u_param, v_param = u, v
418
+ r_u = vec3(
419
+ -r * math.sin(u_param) * math.cos(v_param),
420
+ -r * math.sin(u_param) * math.sin(v_param),
421
+ r * math.cos(u_param)
422
+ )
423
+ r_v = vec3(
424
+ -(R + r * math.cos(u_param)) * math.sin(v_param),
425
+ (R + r * math.cos(u_param)) * math.cos(v_param),
426
+ 0
427
+ )
428
+ else:
429
+ r_u = self.surface.tangent_u(u, v)
430
+ r_v = self.surface.tangent_v(u, v)
431
+
432
+ # 计算第二基本形式系数
433
+ L = -dn_du.dot(r_u)
434
+ M = -dn_du.dot(r_v)
435
+ N = -dn_dv.dot(r_v)
436
+
437
+ # 计算度量张量
438
+ E = r_u.dot(r_u)
439
+ F = r_u.dot(r_v)
440
+ G_metric = r_v.dot(r_v)
441
+ det_g = E * G_metric - F * F
442
+
443
+ # 对于2D曲面,黎曼曲率张量只有一个独立分量
444
+ # R^1_212 与高斯曲率的关系为:K = R^1_212 / det(g)
445
+ # 所以 R^1_212 = K * det(g) = (LN - M²)
446
+
447
+ R_1212 = L * N - M * M
448
+
449
+ # 比例修正(对于某些参数化可能需要)
450
+ if proportional_correction and isinstance(self.surface, Sphere):
451
+ # 对于球面的某些参数化,可能需要额外的修正
452
+ # 但是基于第二基本形式的计算通常不需要
453
+ pass
454
+
455
+ return R_1212
456
+
360
457
  def compute_mean_curvature(self, u: float, v: float) -> float:
361
458
  """
362
459
  Compute mean curvature
@@ -475,6 +572,29 @@ def compute_mean_curvature(
475
572
  return calc.compute_mean_curvature(u, v)
476
573
 
477
574
 
575
+ def compute_riemann_curvature(
576
+ surface: Surface,
577
+ u: float,
578
+ v: float,
579
+ step_size: float = 1e-3,
580
+ proportional_correction: bool = True
581
+ ) -> float:
582
+ """
583
+ Compute Riemann curvature tensor component R^1_212
584
+
585
+ Args:
586
+ surface: Surface object
587
+ u, v: Parameter values
588
+ step_size: Step size for numerical differentiation
589
+ proportional_correction: Apply proportional correction for spherical coordinates
590
+
591
+ Returns:
592
+ Riemann curvature tensor component R^1_212
593
+ """
594
+ calc = IntrinsicGradientCurvatureCalculator(surface, step_size)
595
+ return calc.compute_riemann_curvature(u, v, proportional_correction)
596
+
597
+
478
598
  def compute_all_curvatures(
479
599
  surface: Surface,
480
600
  u: float,
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: coordinate_system
3
- Version: 2.5.7
4
- Summary: High-performance 3D coordinate system library with Intrinsic Gradient Operator method for curvature computation, achieving machine-precision accuracy
3
+ Version: 3.0.0
4
+ Summary: High-performance 3D coordinate system library with right-handed conventions, Intrinsic Gradient Operator method for curvature computation, achieving machine-precision accuracy
5
5
  Home-page: https://github.com/panguojun/Coordinate-System
6
6
  Author: PanGuoJun
7
7
  Author-email: 18858146@qq.com
@@ -48,20 +48,27 @@ 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.1
51
+ **Version:** 3.0.0
52
52
  **License:** MIT
53
53
 
54
- ## 🆕 What's New in v2.4.0
54
+ ## 🆕 What's New in v3.0.0
55
55
 
56
- **Critical Fix & Enhancement Release!**
56
+ **Critical Coordinate System Update - Right-Hand System!**
57
57
 
58
- - 🔧 **Fixed Curvature Extraction** - Corrected antisymmetric part extraction: `K = (R_01 - R_10)/(2·det(g))`
59
- - **Machine Precision Accuracy** - Gaussian curvature now achieves **0.000% error** on spheres (machine precision)!
60
- - **New Convenience Functions** - Added `coord3.identity()`, `coord3.zero()`, `coord3.from_position()`, `coord3.from_rotation()`
61
- - 📚 **Updated Documentation** - Complete mathematical foundation with verified formulas
62
- - 🎯 **Removed Experimental Code** - Eliminated incorrect π division hack
58
+ - ⚠️ **BREAKING CHANGE: Right-Hand Coordinate System** - Unified all operations to standard right-hand coordinate system
59
+ - `vec3.cross()` now uses right-hand rule (standard mathematical definition)
60
+ - Quaternion rotations follow right-hand convention (counter-clockwise is positive)
61
+ - `coord3.look_at()` and `coord3.from_forward()` updated accordingly
62
+ - **Migration Guide:** See [HANDEDNESS_CHANGE.md](HANDEDNESS_CHANGE.md) for details
63
+ - `cross_left()` method retained for backward compatibility
64
+ - ✅ **Verified Correctness** - Complete test suite validates right-hand system behavior
65
+ - 📚 **Updated Documentation** - All examples and documentation reflect new coordinate system
66
+ - 🎯 **Enhanced Clarity** - Comments and docstrings clarified throughout
63
67
 
64
- **Breaking Change:** Previous versions had ~2.5% error due to incorrect curvature extraction. This version fixes the fundamental formula to achieve theoretical accuracy.
68
+ **Why This Change:**
69
+ 1. Mathematical Standard: Right-hand system is the standard in mathematics and physics
70
+ 2. Better Interoperability: Compatible with OpenGL, NumPy, SciPy, and most scientific libraries
71
+ 3. Improved Readability: Standard cross product formulas match textbook definitions
65
72
 
66
73
  Perfect for computational geometry, geometric analysis, and discrete differential geometry research!
67
74
 
@@ -106,15 +113,8 @@ Perfect for computational geometry, geometric analysis, and discrete differentia
106
113
 
107
114
  For a comprehensive understanding of the mathematical principles behind coordinate systems, vectors, quaternions, and transformations, see our detailed mathematical guide:
108
115
 
109
- **[📖 Mathematical Foundation of Coordinate Systems](https://github.com/panguojun/Coordinate-System/blob/main/MATHEMATICAL_FOUNDATION.md)**
116
+ **[📖 Mathematical Foundation of Coordinate Systems](https://github.com/panguojun/Coordinate-System)**
110
117
 
111
- This guide covers:
112
- - Vector mathematics (dot product, cross product, projections)
113
- - Quaternion theory and applications
114
- - Coordinate system transformations
115
- - Euler angles and gimbal lock
116
- - Interpolation methods (LERP, SLERP, NLERP)
117
- - Practical applications in graphics, physics, and robotics
118
118
 
119
119
  ---
120
120
 
@@ -192,19 +192,27 @@ lerped = vec3.lerp(v1, v2, 0.5) # Linear interpolation
192
192
 
193
193
  ## Coordinate System Type
194
194
 
195
- This library uses a **left-handed coordinate system** for all vector and quaternion operations.
195
+ This library uses a **right-handed coordinate system** for all vector and quaternion operations (as of v3.0.0).
196
196
 
197
197
  ```
198
- +Y
199
- |
200
- |
201
- |
202
- +-----> +X
203
- /
204
- /
205
- +Z
198
+ +Y
199
+ |
200
+ |
201
+ |
202
+ +-----> +X
203
+ /
204
+ /
205
+ +Z
206
206
  ```
207
207
 
208
+ **Right-Hand Rule:**
209
+ - Point your right hand's fingers along the +X axis
210
+ - Curl them toward the +Y axis
211
+ - Your thumb points along the +Z axis
212
+ - Cross product: **X × Y = Z** (standard mathematical definition)
213
+
214
+ **Migration from v2.x:** If your code relied on the previous left-handed system, see [HANDEDNESS_CHANGE.md](HANDEDNESS_CHANGE.md) for migration instructions.
215
+
208
216
  ---
209
217
 
210
218
  ## API Reference
@@ -425,7 +433,7 @@ v4 = v1 * 5 # vec3(5, 0, 0)
425
433
 
426
434
  # Dot and cross products
427
435
  dot = v1.dot(v2) # 0.0 (perpendicular)
428
- cross = v1.cross(v2) # vec3(0, 0, 1) in left-handed system
436
+ cross = v1.cross(v2) # vec3(0, 0, 1) in right-handed system (X × Y = Z)
429
437
 
430
438
  # Length and normalization
431
439
  length = v1.length() # 1.0
@@ -0,0 +1,9 @@
1
+ coordinate_system/__init__.py,sha256=fiZ_kmJ0bEZ1aExSVW8iKFNe7FDSSZrlYzkgfL0c4WM,8179
2
+ coordinate_system/coordinate_system.cp313-win_amd64.pyd,sha256=5l4DM78PIS7luFyd8cvj_NEiHhSxHBXdYRuOQeTN5nQ,502272
3
+ coordinate_system/curvature.py,sha256=zrgY9QEuFq2tz0HB4mvXfPV-GwMpeE-F5cM--U8Ihfo,11541
4
+ coordinate_system/differential_geometry.py,sha256=Ih9hwpIntkZ0XNplXAvBfaR2PjBc5UZEV-PGmY9hj0U,20622
5
+ coordinate_system-3.0.0.dist-info/LICENSE,sha256=tDnRkJxBYPzWdfh2gArRqrUPJxQZRZHJVs68qqBHIq4,1083
6
+ coordinate_system-3.0.0.dist-info/METADATA,sha256=aWwFagghmZdcNKbR-j5W6a2IDl4FlT_dsQeSDkXu_tM,19930
7
+ coordinate_system-3.0.0.dist-info/WHEEL,sha256=4-iQBlRoDdX1wfPofc7KLWa5Cys4eZSgXs6GVU8fKlQ,101
8
+ coordinate_system-3.0.0.dist-info/top_level.txt,sha256=R6LguuPPZ5esrIsDTqPGi9UxCvZPIXwn7KRKX87c79M,18
9
+ coordinate_system-3.0.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- coordinate_system/__init__.py,sha256=ghiaCYoPi1XPBSI5NFXDZHViUa5B_Eni5M2M-sogVUA,7535
2
- coordinate_system/coordinate_system.cp313-win_amd64.pyd,sha256=fxFctfhWhMbKSVyXAxOTGfgvpcEhe41SfxIz6bMVy3E,497152
3
- coordinate_system/curvature.py,sha256=zrgY9QEuFq2tz0HB4mvXfPV-GwMpeE-F5cM--U8Ihfo,11541
4
- coordinate_system/differential_geometry.py,sha256=mbXMxkw1GhMdBKK_-AmH7LT019pUgPlws7XkFawHh-U,16123
5
- coordinate_system-2.5.7.dist-info/LICENSE,sha256=tDnRkJxBYPzWdfh2gArRqrUPJxQZRZHJVs68qqBHIq4,1083
6
- coordinate_system-2.5.7.dist-info/METADATA,sha256=rvGygmDMkPOjVvgWiESHljkf3PrT4X5A2SJ9nLXZpts,19428
7
- coordinate_system-2.5.7.dist-info/WHEEL,sha256=4-iQBlRoDdX1wfPofc7KLWa5Cys4eZSgXs6GVU8fKlQ,101
8
- coordinate_system-2.5.7.dist-info/top_level.txt,sha256=R6LguuPPZ5esrIsDTqPGi9UxCvZPIXwn7KRKX87c79M,18
9
- coordinate_system-2.5.7.dist-info/RECORD,,