coordinate-system 2.5.1__cp313-cp313-win_amd64.whl → 2.5.3__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.
@@ -1,283 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """
4
- Two-Stage Adaptive Curvature Computation
5
- 基于两级自适应修正的曲率计算
6
-
7
- 理论基础:
8
- 1. 离散化误差与真实曲率成正比:ε ∝ K_true
9
- 2. 投影协变破坏在李括号中被线性放大
10
- 3. 通过快速估算打破曲率嵌套的自指循环
11
- """
12
-
13
- from typing import Optional
14
- import numpy as np
15
-
16
- # ========== Stage 1: Fast Curvature Scale Estimation ==========
17
-
18
- def estimate_curvature_scale(
19
- surface,
20
- u: float,
21
- v: float,
22
- h: float = 1e-3
23
- ) -> float:
24
- """
25
- 第1级:快速曲率标量估计
26
-
27
- 基于法向量变化的几何直觉:
28
- 曲率越大,法向量变化越快
29
-
30
- Args:
31
- surface: 曲面对象
32
- u, v: 参数坐标
33
- h: 步长
34
-
35
- Returns:
36
- 粗估的曲率标量 K_rough
37
- """
38
- # 计算中心点和邻域点的法向量
39
- n_center = surface.normal(u, v)
40
- n_u_plus = surface.normal(u + h, v)
41
- n_v_plus = surface.normal(u, v + h)
42
-
43
- # 法向量变化的平均值(几何直觉)
44
- dn_u = (n_u_plus - n_center).len()
45
- dn_v = (n_v_plus - n_center).len()
46
-
47
- # 粗估曲率:法向量变化率的平均
48
- K_rough = (dn_u + dn_v) / (2.0 * h)
49
-
50
- return K_rough
51
-
52
-
53
- def estimate_curvature_from_metric(
54
- surface,
55
- u: float,
56
- v: float,
57
- h: float = 1e-3
58
- ) -> float:
59
- """
60
- 基于度量张量变化的曲率估计(备用方法)
61
-
62
- 通过度量张量的二阶导数粗估曲率
63
- """
64
- from coordinate_system.differential_geometry import compute_metric
65
-
66
- # 计算度量张量
67
- g = compute_metric(surface, u, v)
68
-
69
- # 简化估计:基于 Gauss 方程的离散近似
70
- # K ≈ -Δ log(√det(g)) / 2
71
-
72
- g_u_plus = compute_metric(surface, u + h, v)
73
- g_u_minus = compute_metric(surface, u - h, v)
74
- g_v_plus = compute_metric(surface, u, v + h)
75
- g_v_minus = compute_metric(surface, u, v - h)
76
-
77
- # 二阶差分
78
- d2_det_u = (g_u_plus.det - 2.0 * g.det + g_u_minus.det) / (h * h)
79
- d2_det_v = (g_v_plus.det - 2.0 * g.det + g_v_minus.det) / (h * h)
80
-
81
- if abs(g.det) > 1e-10:
82
- K_rough = -(d2_det_u + d2_det_v) / (2.0 * g.det)
83
- else:
84
- K_rough = 0.0
85
-
86
- return K_rough
87
-
88
-
89
- # ========== Stage 2: Adaptive Correction Factor ==========
90
-
91
- def compute_adaptive_beta(
92
- K_estimate: float,
93
- beta_0: float = 0.75,
94
- alpha: float = 0.1,
95
- gamma: float = 2.0
96
- ) -> float:
97
- """
98
- 第2级:计算自适应修正因子
99
-
100
- 基于曲率估计的修正因子:
101
- β(K) = β_0 × (1 + α × tanh(γ × K_estimate))
102
-
103
- 物理意义:
104
- - β_0 = 0.75: 基准修正因子,补偿投影协变破坏
105
- - α: 曲率依赖的调节参数
106
- - γ: 曲率响应的敏感度
107
-
108
- Args:
109
- K_estimate: 第1级估算的曲率标量
110
- beta_0: 基准修正因子(默认 0.75)
111
- alpha: 调节参数
112
- gamma: 敏感度参数
113
-
114
- Returns:
115
- 自适应修正因子 β
116
- """
117
- # 使用 tanh 函数实现平滑的非线性响应
118
- beta = beta_0 * (1.0 + alpha * np.tanh(gamma * abs(K_estimate)))
119
-
120
- return beta
121
-
122
-
123
- def compute_simple_beta(K_estimate: float) -> float:
124
- """
125
- 简化版修正因子(固定值)
126
-
127
- 基于经验观察:投影协变破坏导致~33%的系统性放大
128
- 因此修正因子 β ≈ 3/4 = 0.75
129
- """
130
- return 0.75
131
-
132
-
133
- # ========== Two-Stage Curvature Computation ==========
134
-
135
- def compute_gaussian_curvature_two_stage(
136
- surface,
137
- u: float,
138
- v: float,
139
- step_size: float = 1e-3,
140
- use_adaptive_beta: bool = True,
141
- beta_0: float = 0.75
142
- ) -> float:
143
- """
144
- 两级自适应曲率计算
145
-
146
- 算法流程:
147
- 1. Stage 1: 快速估算曲率标量 K_rough
148
- 2. Stage 2: 计算自适应修正因子 β(K_rough)
149
- 3. 应用修正因子到精确曲率计算
150
-
151
- Args:
152
- surface: 曲面对象
153
- u, v: 参数坐标
154
- step_size: 数值微分步长
155
- use_adaptive_beta: 是否使用自适应修正因子
156
- beta_0: 基准修正因子
157
-
158
- Returns:
159
- 修正后的高斯曲率 K
160
-
161
- Example:
162
- >>> sphere = Sphere(radius=1.0)
163
- >>> K = compute_gaussian_curvature_two_stage(sphere, np.pi/2, np.pi/4)
164
- >>> print(f"K = {K:.6f}") # 应接近 1.0
165
- """
166
- # === Stage 1: 快速曲率标量估计 ===
167
- K_rough = estimate_curvature_scale(surface, u, v, step_size)
168
-
169
- # === Stage 2: 自适应修正因子 ===
170
- if use_adaptive_beta:
171
- beta = compute_adaptive_beta(K_rough, beta_0=beta_0)
172
- else:
173
- beta = beta_0
174
-
175
- # === 精确曲率张量计算 ===
176
- # 导入避免循环依赖
177
- from coordinate_system.differential_geometry import compute_curvature_tensor, compute_metric
178
-
179
- R_uv = compute_curvature_tensor(
180
- surface, u, v,
181
- scale_factor=1.0, # 不在这里应用 scale_factor
182
- use_metric_correction=True,
183
- use_lie_derivative=False, # 简化版不使用李导数项
184
- step_size=step_size
185
- )
186
-
187
- g = compute_metric(surface, u, v)
188
-
189
- # 提取反对称部分
190
- R_01 = R_uv.ux.y
191
- R_10 = R_uv.uy.x
192
- R_12_antisym = (R_01 - R_10) / 2.0
193
-
194
- # 原始曲率(未修正)
195
- if abs(g.det) > 1e-10:
196
- K_raw = R_12_antisym / g.det
197
- else:
198
- K_raw = 0.0
199
-
200
- # === 应用修正因子 ===
201
- K_corrected = beta * K_raw
202
-
203
- return K_corrected
204
-
205
-
206
- # ========== Enhanced Version with Iterative Refinement ==========
207
-
208
- def compute_gaussian_curvature_iterative(
209
- surface,
210
- u: float,
211
- v: float,
212
- step_size: float = 1e-3,
213
- max_iterations: int = 3,
214
- tolerance: float = 1e-4
215
- ) -> float:
216
- """
217
- 迭代精化版本的两级曲率计算
218
-
219
- 通过迭代更新修正因子,进一步提高精度:
220
- 1. 初始估计 K^(0)
221
- 2. 计算 β^(1) = f(K^(0))
222
- 3. 更新 K^(1) = β^(1) × K_raw
223
- 4. 重复直到收敛
224
-
225
- Args:
226
- surface: 曲面对象
227
- u, v: 参数坐标
228
- step_size: 数值微分步长
229
- max_iterations: 最大迭代次数
230
- tolerance: 收敛判据
231
-
232
- Returns:
233
- 迭代收敛后的高斯曲率 K
234
- """
235
- # 初始估计
236
- K_prev = estimate_curvature_scale(surface, u, v, step_size)
237
-
238
- # 计算原始曲率(只计算一次)
239
- from coordinate_system.differential_geometry import compute_curvature_tensor, compute_metric
240
-
241
- R_uv = compute_curvature_tensor(
242
- surface, u, v,
243
- scale_factor=1.0,
244
- use_metric_correction=True,
245
- use_lie_derivative=False,
246
- step_size=step_size
247
- )
248
-
249
- g = compute_metric(surface, u, v)
250
- R_01 = R_uv.ux.y
251
- R_10 = R_uv.uy.x
252
- R_12_antisym = (R_01 - R_10) / 2.0
253
-
254
- if abs(g.det) > 1e-10:
255
- K_raw = R_12_antisym / g.det
256
- else:
257
- return 0.0
258
-
259
- # 迭代精化
260
- for iteration in range(max_iterations):
261
- # 基于上一次估计计算修正因子
262
- beta = compute_adaptive_beta(K_prev)
263
-
264
- # 更新曲率估计
265
- K_new = beta * K_raw
266
-
267
- # 检查收敛
268
- if abs(K_new - K_prev) < tolerance:
269
- return K_new
270
-
271
- K_prev = K_new
272
-
273
- return K_prev
274
-
275
-
276
- __all__ = [
277
- 'estimate_curvature_scale',
278
- 'estimate_curvature_from_metric',
279
- 'compute_adaptive_beta',
280
- 'compute_simple_beta',
281
- 'compute_gaussian_curvature_two_stage',
282
- 'compute_gaussian_curvature_iterative',
283
- ]
@@ -1,11 +0,0 @@
1
- coordinate_system/__init__.py,sha256=CXmYl15vYthXaP4DF6fiLwH0oiBvit-zf9n3rE7DijI,7939
2
- coordinate_system/coordinate_system.cp313-win_amd64.pyd,sha256=Rp2rgehlW-TUG3xwj9qjOWeOGNEqrPMo5U4rWu2WWns,494080
3
- coordinate_system/curvature.py,sha256=m4damAauBosQHr50bJxazv8JzdCfaCAqnEWC6P9NkCk,27022
4
- coordinate_system/differential_geometry.py,sha256=P3GhfoZ8WHLSE3AmpzdlaEII7E9QsZsERiznXaBaKRc,17036
5
- coordinate_system/intrinsic_gradient_curvature.py,sha256=CVWMP5JgsKerIViii2vsFy-d_PCtB02ZIJ9fi8qmCVA,17680
6
- coordinate_system/two_stage_curvature.py,sha256=e4fYAhiUc8NwtBi5hz5se4if4i8zZzG8smNlWNwuJpw,7219
7
- coordinate_system-2.5.1.dist-info/LICENSE,sha256=tDnRkJxBYPzWdfh2gArRqrUPJxQZRZHJVs68qqBHIq4,1083
8
- coordinate_system-2.5.1.dist-info/METADATA,sha256=wzxf4SxNT3WXvArk1zpTeu10Wh9rXqw8pxDZMFq1xMU,19428
9
- coordinate_system-2.5.1.dist-info/WHEEL,sha256=4-iQBlRoDdX1wfPofc7KLWa5Cys4eZSgXs6GVU8fKlQ,101
10
- coordinate_system-2.5.1.dist-info/top_level.txt,sha256=R6LguuPPZ5esrIsDTqPGi9UxCvZPIXwn7KRKX87c79M,18
11
- coordinate_system-2.5.1.dist-info/RECORD,,