coordinate-system 2.4.2__cp313-cp313-win_amd64.whl → 2.5.1__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.
- coordinate_system/__init__.py +48 -24
- coordinate_system/coordinate_system.cp313-win_amd64.pyd +0 -0
- coordinate_system/curvature.py +38 -14
- coordinate_system/differential_geometry.py +302 -591
- coordinate_system/intrinsic_gradient_curvature.py +533 -0
- {coordinate_system-2.4.2.dist-info → coordinate_system-2.5.1.dist-info}/METADATA +3 -3
- coordinate_system-2.5.1.dist-info/RECORD +11 -0
- coordinate_system-2.4.2.dist-info/RECORD +0 -10
- {coordinate_system-2.4.2.dist-info → coordinate_system-2.5.1.dist-info}/LICENSE +0 -0
- {coordinate_system-2.4.2.dist-info → coordinate_system-2.5.1.dist-info}/WHEEL +0 -0
- {coordinate_system-2.4.2.dist-info → coordinate_system-2.5.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Intrinsic Gradient Operator Based Curvature Calculation Module
|
|
3
|
+
==============================================================
|
|
4
|
+
|
|
5
|
+
This module implements surface curvature calculation based on the Intrinsic Gradient Operator method.
|
|
6
|
+
The method defines the intrinsic gradient operator G_μ = (c(u+h) - c(u))/h, transforming the
|
|
7
|
+
calculation of surface geometric properties into the analysis of coordinate system changes.
|
|
8
|
+
|
|
9
|
+
Theoretical Basis:
|
|
10
|
+
-----------------
|
|
11
|
+
1. Intrinsic gradient operator definition: G_μ = (c(u+h_μ) - c(u))/h_μ
|
|
12
|
+
where c(u,v) is the intrinsic frame on the surface
|
|
13
|
+
|
|
14
|
+
2. Geometric meaning of intrinsic gradient operator:
|
|
15
|
+
- G_μ.ux, G_μ.uy: rotation and deformation of tangent space
|
|
16
|
+
- G_μ.uz: rate of change of normal vector, i.e., ∂n/∂μ
|
|
17
|
+
- G_μ.s: change of metric scaling factor
|
|
18
|
+
|
|
19
|
+
3. Second fundamental form calculation:
|
|
20
|
+
- L = -∂n/∂u · f_u = -G_u.uz · f_u
|
|
21
|
+
- M = -1/2(∂n/∂u · f_v + ∂n/∂v · f_u)
|
|
22
|
+
- N = -∂n/∂v · f_v = -G_v.uz · f_v
|
|
23
|
+
|
|
24
|
+
4. Gaussian curvature: K = (LN - M²) / det(g)
|
|
25
|
+
|
|
26
|
+
Advantages:
|
|
27
|
+
----------
|
|
28
|
+
- Numerical stability: avoids complex tensor operations and high-order derivatives
|
|
29
|
+
- Geometric intuition: transforms curvature concepts into coordinate system change analysis
|
|
30
|
+
- Computational efficiency: mainly involves basic vector operations and finite differences
|
|
31
|
+
- Intrinsic-embedding synergy: combines advantages of intrinsic and embedding frames
|
|
32
|
+
|
|
33
|
+
Author: PanGuoJun
|
|
34
|
+
Version: 1.0.0
|
|
35
|
+
Date: 2025-10-30
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
import numpy as np
|
|
39
|
+
from typing import Tuple, Optional, Dict, Union
|
|
40
|
+
from .coordinate_system import coord3, vec3
|
|
41
|
+
from .differential_geometry import Surface, MetricTensor
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class IntrinsicGradientOperator:
|
|
45
|
+
"""
|
|
46
|
+
Intrinsic Gradient Operator Class
|
|
47
|
+
|
|
48
|
+
Implements calculation of intrinsic gradient operator G_μ = (c(u+h) - c(u))/h,
|
|
49
|
+
used for analyzing local changes in surface geometric properties.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
def __init__(self, surface: Surface, step_size: float = 1e-4):
|
|
53
|
+
"""
|
|
54
|
+
Initialize intrinsic gradient operator
|
|
55
|
+
|
|
56
|
+
Parameters:
|
|
57
|
+
surface: Surface object
|
|
58
|
+
step_size: finite difference step size (default: 1e-4)
|
|
59
|
+
"""
|
|
60
|
+
self.surface = surface
|
|
61
|
+
self.h = step_size
|
|
62
|
+
|
|
63
|
+
def compute_intrinsic_frame(self, u: float, v: float) -> coord3:
|
|
64
|
+
"""
|
|
65
|
+
Compute intrinsic frame c(u,v)
|
|
66
|
+
|
|
67
|
+
Intrinsic frame consists of orthonormalized tangent vectors and normal vector:
|
|
68
|
+
c = (e_u, e_v, n)
|
|
69
|
+
where e_u, e_v are unit tangent vectors obtained through Gram-Schmidt orthogonalization
|
|
70
|
+
|
|
71
|
+
Parameters:
|
|
72
|
+
u, v: parameter coordinates
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
coord3 object containing orthonormalized basis vectors
|
|
76
|
+
"""
|
|
77
|
+
# Compute tangent vectors
|
|
78
|
+
r_u = self.surface.tangent_u(u, v)
|
|
79
|
+
r_v = self.surface.tangent_v(u, v)
|
|
80
|
+
|
|
81
|
+
# Gram-Schmidt orthogonalization
|
|
82
|
+
e1 = r_u.normcopy() # First basis vector: normalized r_u
|
|
83
|
+
|
|
84
|
+
# Second basis vector: projection of r_v onto orthogonal complement of e1
|
|
85
|
+
r_v_orth = r_v - e1 * r_v.dot(e1)
|
|
86
|
+
e2 = r_v_orth.normcopy()
|
|
87
|
+
|
|
88
|
+
# Third basis vector: normal vector
|
|
89
|
+
n = e1.cross(e2).normcopy()
|
|
90
|
+
|
|
91
|
+
# Create intrinsic frame
|
|
92
|
+
return coord3(e1, e2, n)
|
|
93
|
+
|
|
94
|
+
def compute_embedding_frame(self, u: float, v: float) -> coord3:
|
|
95
|
+
"""
|
|
96
|
+
Compute embedding frame C(u,v)
|
|
97
|
+
|
|
98
|
+
Embedding frame preserves metric information through Gram-Schmidt orthogonalization
|
|
99
|
+
while maintaining tangent vector lengths:
|
|
100
|
+
C = (f_u, f_v, n)
|
|
101
|
+
where f_u, f_v are orthogonalized tangent vectors with preserved lengths
|
|
102
|
+
|
|
103
|
+
Parameters:
|
|
104
|
+
u, v: parameter coordinates
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
coord3 object preserving metric information
|
|
108
|
+
"""
|
|
109
|
+
# Compute tangent vectors
|
|
110
|
+
r_u = self.surface.tangent_u(u, v)
|
|
111
|
+
r_v = self.surface.tangent_v(u, v)
|
|
112
|
+
|
|
113
|
+
# Gram-Schmidt orthogonalization (preserving metric information)
|
|
114
|
+
e1 = r_u.normcopy()
|
|
115
|
+
e1_length = (r_u.x**2 + r_u.y**2 + r_u.z**2) ** 0.5
|
|
116
|
+
|
|
117
|
+
# Projection of r_v onto orthogonal complement of e1
|
|
118
|
+
proj = r_v.dot(e1)
|
|
119
|
+
r_v_orth = r_v - e1 * proj
|
|
120
|
+
e2 = r_v_orth.normcopy()
|
|
121
|
+
e2_length = (r_v_orth.x**2 + r_v_orth.y**2 + r_v_orth.z**2) ** 0.5
|
|
122
|
+
|
|
123
|
+
# Normal vector (already normalized)
|
|
124
|
+
n = e1.cross(e2).normcopy()
|
|
125
|
+
|
|
126
|
+
# Create embedding frame, preserving metric information
|
|
127
|
+
# Using 5-parameter constructor: coord3(origin, scale, ux, uy, uz)
|
|
128
|
+
origin = self.surface.position(u, v)
|
|
129
|
+
scale = vec3(e1_length, e2_length, 1.0)
|
|
130
|
+
|
|
131
|
+
return coord3(origin, scale, e1, e2, n)
|
|
132
|
+
|
|
133
|
+
def compute(self, u: float, v: float, direction: str = 'u') -> coord3:
|
|
134
|
+
"""
|
|
135
|
+
Compute intrinsic gradient operator G_μ
|
|
136
|
+
|
|
137
|
+
Using definition: G_μ = (c(u+h) - c(u))/h
|
|
138
|
+
|
|
139
|
+
Parameters:
|
|
140
|
+
u, v: parameter coordinates
|
|
141
|
+
direction: 'u' or 'v', calculation direction
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
coord3 object representing intrinsic gradient operator
|
|
145
|
+
"""
|
|
146
|
+
# Compute intrinsic frame at center point
|
|
147
|
+
c_center = self.compute_intrinsic_frame(u, v)
|
|
148
|
+
|
|
149
|
+
# Compute intrinsic frame at shifted point
|
|
150
|
+
if direction == 'u':
|
|
151
|
+
c_shifted = self.compute_intrinsic_frame(u + self.h, v)
|
|
152
|
+
elif direction == 'v':
|
|
153
|
+
c_shifted = self.compute_intrinsic_frame(u, v + self.h)
|
|
154
|
+
else:
|
|
155
|
+
raise ValueError(f"direction must be 'u' or 'v', got: {direction}")
|
|
156
|
+
|
|
157
|
+
# Intrinsic gradient operator: G_μ = (c(u+h) - c(u))/h
|
|
158
|
+
# Note: coord3 subtraction normalizes scale to (1,1,1), need manual scaling
|
|
159
|
+
G_raw = c_shifted - c_center
|
|
160
|
+
|
|
161
|
+
# Divide by step size to get derivative
|
|
162
|
+
if abs(self.h) > 1e-14:
|
|
163
|
+
h_inv = 1.0 / self.h
|
|
164
|
+
# Scale the scale vector
|
|
165
|
+
scaled_s = vec3(G_raw.s.x * h_inv, G_raw.s.y * h_inv, G_raw.s.z * h_inv)
|
|
166
|
+
G = coord3(G_raw.o, scaled_s, G_raw.ux, G_raw.uy, G_raw.uz)
|
|
167
|
+
else:
|
|
168
|
+
G = G_raw
|
|
169
|
+
|
|
170
|
+
return G
|
|
171
|
+
|
|
172
|
+
def compute_both(self, u: float, v: float) -> Tuple[coord3, coord3]:
|
|
173
|
+
"""
|
|
174
|
+
Compute intrinsic gradient operators in both directions simultaneously
|
|
175
|
+
|
|
176
|
+
Parameters:
|
|
177
|
+
u, v: parameter coordinates
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
Tuple of (G_u, G_v)
|
|
181
|
+
"""
|
|
182
|
+
G_u = self.compute(u, v, 'u')
|
|
183
|
+
G_v = self.compute(u, v, 'v')
|
|
184
|
+
return G_u, G_v
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class IntrinsicGradientCurvatureCalculator:
|
|
188
|
+
"""
|
|
189
|
+
Curvature calculator based on intrinsic gradient operator
|
|
190
|
+
|
|
191
|
+
Uses intrinsic gradient operator method to calculate various surface curvatures:
|
|
192
|
+
1. Compute intrinsic gradient operators G_u, G_v
|
|
193
|
+
2. Extract normal vector derivatives ∂n/∂u, ∂n/∂v from G_u.uz, G_v.uz
|
|
194
|
+
3. Compute second fundamental form L, M, N
|
|
195
|
+
4. Compute Gaussian curvature K = (LN - M²)/det(g)
|
|
196
|
+
"""
|
|
197
|
+
|
|
198
|
+
def __init__(self, surface: Surface, step_size: float = 1e-4):
|
|
199
|
+
"""
|
|
200
|
+
Initialize curvature calculator
|
|
201
|
+
|
|
202
|
+
Parameters:
|
|
203
|
+
surface: Surface object
|
|
204
|
+
step_size: finite difference step size (default: 1e-4)
|
|
205
|
+
Recommended range: 1e-5 to 1e-3
|
|
206
|
+
"""
|
|
207
|
+
self.surface = surface
|
|
208
|
+
self.h = step_size
|
|
209
|
+
self.intrinsic_grad = IntrinsicGradientOperator(surface, step_size)
|
|
210
|
+
|
|
211
|
+
def compute_second_fundamental_form(self, u: float, v: float) -> Tuple[float, float, float]:
|
|
212
|
+
"""
|
|
213
|
+
Compute second fundamental form coefficients L, M, N
|
|
214
|
+
|
|
215
|
+
Using intrinsic gradient operator method:
|
|
216
|
+
L = -∂n/∂u · r_u = -G_u.uz · r_u
|
|
217
|
+
M = -1/2(∂n/∂u · r_v + ∂n/∂v · r_u)
|
|
218
|
+
N = -∂n/∂v · r_v = -G_v.uz · r_v
|
|
219
|
+
|
|
220
|
+
Parameters:
|
|
221
|
+
u, v: parameter coordinates
|
|
222
|
+
|
|
223
|
+
Returns:
|
|
224
|
+
Tuple of (L, M, N)
|
|
225
|
+
"""
|
|
226
|
+
# Compute intrinsic gradient operators
|
|
227
|
+
G_u, G_v = self.intrinsic_grad.compute_both(u, v)
|
|
228
|
+
|
|
229
|
+
# Compute tangent vectors
|
|
230
|
+
r_u = self.surface.tangent_u(u, v)
|
|
231
|
+
r_v = self.surface.tangent_v(u, v)
|
|
232
|
+
|
|
233
|
+
# Extract normal vector derivatives (stored in uz components)
|
|
234
|
+
dn_du = vec3(G_u.uz.x, G_u.uz.y, G_u.uz.z)
|
|
235
|
+
dn_dv = vec3(G_v.uz.x, G_v.uz.y, G_v.uz.z)
|
|
236
|
+
|
|
237
|
+
# Compute second fundamental form coefficients
|
|
238
|
+
L = -dn_du.dot(r_u)
|
|
239
|
+
M1 = -dn_du.dot(r_v)
|
|
240
|
+
M2 = -dn_dv.dot(r_u)
|
|
241
|
+
M = (M1 + M2) / 2.0 # Symmetrization
|
|
242
|
+
N = -dn_dv.dot(r_v)
|
|
243
|
+
|
|
244
|
+
return L, M, N
|
|
245
|
+
|
|
246
|
+
def compute_gaussian_curvature(self, u: float, v: float) -> float:
|
|
247
|
+
"""
|
|
248
|
+
Compute Gaussian curvature using intrinsic gradient operator
|
|
249
|
+
|
|
250
|
+
Formula: K = (LN - M²) / det(g)
|
|
251
|
+
|
|
252
|
+
Parameters:
|
|
253
|
+
u, v: parameter coordinates
|
|
254
|
+
|
|
255
|
+
Returns:
|
|
256
|
+
Gaussian curvature K
|
|
257
|
+
|
|
258
|
+
Example:
|
|
259
|
+
>>> from coordinate_system import Sphere
|
|
260
|
+
>>> sphere = Sphere(radius=2.0)
|
|
261
|
+
>>> calc = IntrinsicGradientCurvatureCalculator(sphere)
|
|
262
|
+
>>> K = calc.compute_gaussian_curvature(np.pi/4, np.pi/6)
|
|
263
|
+
>>> print(f"K = {K:.6f}, theoretical = 0.250000")
|
|
264
|
+
"""
|
|
265
|
+
# Compute embedding frame and metric
|
|
266
|
+
C = self.intrinsic_grad.compute_embedding_frame(u, v)
|
|
267
|
+
metric = MetricTensor.from_coord3(C)
|
|
268
|
+
|
|
269
|
+
# Compute second fundamental form
|
|
270
|
+
L, M, N = self.compute_second_fundamental_form(u, v)
|
|
271
|
+
|
|
272
|
+
# Gaussian curvature
|
|
273
|
+
if abs(metric.det) > 1e-14:
|
|
274
|
+
K = (L * N - M * M) / metric.det
|
|
275
|
+
else:
|
|
276
|
+
K = 0.0
|
|
277
|
+
|
|
278
|
+
return K
|
|
279
|
+
|
|
280
|
+
def compute_mean_curvature(self, u: float, v: float) -> float:
|
|
281
|
+
"""
|
|
282
|
+
Compute mean curvature using intrinsic gradient operator
|
|
283
|
+
|
|
284
|
+
Formula: H = (EN - 2FM + GL) / (2·det(g))
|
|
285
|
+
|
|
286
|
+
Parameters:
|
|
287
|
+
u, v: parameter coordinates
|
|
288
|
+
|
|
289
|
+
Returns:
|
|
290
|
+
Mean curvature H
|
|
291
|
+
"""
|
|
292
|
+
# Compute embedding frame and metric
|
|
293
|
+
C = self.intrinsic_grad.compute_embedding_frame(u, v)
|
|
294
|
+
metric = MetricTensor.from_coord3(C)
|
|
295
|
+
|
|
296
|
+
# Compute second fundamental form
|
|
297
|
+
L, M, N = self.compute_second_fundamental_form(u, v)
|
|
298
|
+
|
|
299
|
+
# Mean curvature
|
|
300
|
+
if abs(metric.det) > 1e-14:
|
|
301
|
+
H = (metric.G * L - 2 * metric.F * M + metric.E * N) / (2 * metric.det)
|
|
302
|
+
else:
|
|
303
|
+
H = 0.0
|
|
304
|
+
|
|
305
|
+
return H
|
|
306
|
+
|
|
307
|
+
def compute_principal_curvatures(self, u: float, v: float) -> Tuple[float, float]:
|
|
308
|
+
"""
|
|
309
|
+
Compute principal curvatures
|
|
310
|
+
|
|
311
|
+
Principal curvatures are eigenvalues of shape operator S = g⁻¹h
|
|
312
|
+
|
|
313
|
+
Parameters:
|
|
314
|
+
u, v: parameter coordinates
|
|
315
|
+
|
|
316
|
+
Returns:
|
|
317
|
+
Tuple of principal curvatures (k1, k2) where |k1| >= |k2|
|
|
318
|
+
"""
|
|
319
|
+
K = self.compute_gaussian_curvature(u, v)
|
|
320
|
+
H = self.compute_mean_curvature(u, v)
|
|
321
|
+
|
|
322
|
+
# Use formula: k1,2 = H ± √(H² - K)
|
|
323
|
+
discriminant = H * H - K
|
|
324
|
+
if discriminant < 0:
|
|
325
|
+
discriminant = 0
|
|
326
|
+
|
|
327
|
+
sqrt_disc = discriminant ** 0.5
|
|
328
|
+
k1 = H + sqrt_disc
|
|
329
|
+
k2 = H - sqrt_disc
|
|
330
|
+
|
|
331
|
+
return k1, k2
|
|
332
|
+
|
|
333
|
+
def compute_all_curvatures(self, u: float, v: float) -> Dict[str, Union[float, Tuple[float, float, float]]]:
|
|
334
|
+
"""
|
|
335
|
+
Compute all curvature-related quantities
|
|
336
|
+
|
|
337
|
+
Parameters:
|
|
338
|
+
u, v: parameter coordinates
|
|
339
|
+
|
|
340
|
+
Returns:
|
|
341
|
+
Dictionary containing the following keys:
|
|
342
|
+
- 'K': Gaussian curvature
|
|
343
|
+
- 'H': Mean curvature
|
|
344
|
+
- 'k1', 'k2': Principal curvatures
|
|
345
|
+
- 'L', 'M', 'N': Second fundamental form coefficients
|
|
346
|
+
- 'det_g': Metric determinant
|
|
347
|
+
"""
|
|
348
|
+
# Compute embedding frame and metric
|
|
349
|
+
C = self.intrinsic_grad.compute_embedding_frame(u, v)
|
|
350
|
+
metric = MetricTensor.from_coord3(C)
|
|
351
|
+
|
|
352
|
+
# Compute second fundamental form
|
|
353
|
+
L, M, N = self.compute_second_fundamental_form(u, v)
|
|
354
|
+
|
|
355
|
+
# Compute curvatures
|
|
356
|
+
if abs(metric.det) > 1e-14:
|
|
357
|
+
K = (L * N - M * M) / metric.det
|
|
358
|
+
H = (metric.G * L - 2 * metric.F * M + metric.E * N) / (2 * metric.det)
|
|
359
|
+
else:
|
|
360
|
+
K = 0.0
|
|
361
|
+
H = 0.0
|
|
362
|
+
|
|
363
|
+
# Principal curvatures
|
|
364
|
+
discriminant = max(0, H * H - K)
|
|
365
|
+
sqrt_disc = discriminant ** 0.5
|
|
366
|
+
k1 = H + sqrt_disc
|
|
367
|
+
k2 = H - sqrt_disc
|
|
368
|
+
|
|
369
|
+
return {
|
|
370
|
+
'K': K,
|
|
371
|
+
'H': H,
|
|
372
|
+
'k1': k1,
|
|
373
|
+
'k2': k2,
|
|
374
|
+
'L': L,
|
|
375
|
+
'M': M,
|
|
376
|
+
'N': N,
|
|
377
|
+
'det_g': metric.det,
|
|
378
|
+
'E': metric.E,
|
|
379
|
+
'F': metric.F,
|
|
380
|
+
'G': metric.G
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
def verify_against_sphere(self, u: float, v: float, radius: float) -> Dict[str, float]:
|
|
384
|
+
"""
|
|
385
|
+
Verify curvature calculation on sphere
|
|
386
|
+
|
|
387
|
+
Used for testing and validating calculation correctness.
|
|
388
|
+
Theoretical values for sphere: K = 1/R², H = 1/R, k1 = k2 = 1/R
|
|
389
|
+
|
|
390
|
+
Parameters:
|
|
391
|
+
u, v: parameter coordinates
|
|
392
|
+
radius: sphere radius
|
|
393
|
+
|
|
394
|
+
Returns:
|
|
395
|
+
Dictionary containing computed values, theoretical values, and errors
|
|
396
|
+
"""
|
|
397
|
+
results = self.compute_all_curvatures(u, v)
|
|
398
|
+
|
|
399
|
+
# Theoretical values
|
|
400
|
+
K_theory = 1.0 / (radius * radius)
|
|
401
|
+
H_theory = 1.0 / radius
|
|
402
|
+
k_theory = 1.0 / radius
|
|
403
|
+
|
|
404
|
+
# Error calculation
|
|
405
|
+
K_error = abs(results['K'] - K_theory) / K_theory * 100 if K_theory != 0 else 0
|
|
406
|
+
H_error = abs(results['H'] - H_theory) / H_theory * 100 if H_theory != 0 else 0
|
|
407
|
+
k1_error = abs(results['k1'] - k_theory) / k_theory * 100 if k_theory != 0 else 0
|
|
408
|
+
k2_error = abs(results['k2'] - k_theory) / k_theory * 100 if k_theory != 0 else 0
|
|
409
|
+
|
|
410
|
+
return {
|
|
411
|
+
'K_computed': results['K'],
|
|
412
|
+
'K_theory': K_theory,
|
|
413
|
+
'K_error_%': K_error,
|
|
414
|
+
'H_computed': results['H'],
|
|
415
|
+
'H_theory': H_theory,
|
|
416
|
+
'H_error_%': H_error,
|
|
417
|
+
'k1_computed': results['k1'],
|
|
418
|
+
'k1_theory': k_theory,
|
|
419
|
+
'k1_error_%': k1_error,
|
|
420
|
+
'k2_computed': results['k2'],
|
|
421
|
+
'k2_theory': k_theory,
|
|
422
|
+
'k2_error_%': k2_error
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
# ========== Simplified Interface Functions ==========
|
|
427
|
+
|
|
428
|
+
def intrinsic_gradient_gaussian_curvature(
|
|
429
|
+
surface: Surface,
|
|
430
|
+
u: float,
|
|
431
|
+
v: float,
|
|
432
|
+
step_size: float = 1e-4
|
|
433
|
+
) -> float:
|
|
434
|
+
"""
|
|
435
|
+
Compute Gaussian curvature using intrinsic gradient operator method (simplified interface)
|
|
436
|
+
|
|
437
|
+
Parameters:
|
|
438
|
+
surface: Surface object
|
|
439
|
+
u, v: parameter coordinates
|
|
440
|
+
step_size: finite difference step size (default: 1e-4)
|
|
441
|
+
|
|
442
|
+
Returns:
|
|
443
|
+
Gaussian curvature K
|
|
444
|
+
|
|
445
|
+
Example:
|
|
446
|
+
>>> from coordinate_system import Sphere
|
|
447
|
+
>>> from coordinate_system.intrinsic_gradient_curvature import intrinsic_gradient_gaussian_curvature
|
|
448
|
+
>>> import math
|
|
449
|
+
>>>
|
|
450
|
+
>>> sphere = Sphere(radius=2.0)
|
|
451
|
+
>>> K = intrinsic_gradient_gaussian_curvature(sphere, math.pi/4, math.pi/6)
|
|
452
|
+
>>> print(f"K = {K:.6f}") # Should output K ≈ 0.250000
|
|
453
|
+
"""
|
|
454
|
+
calc = IntrinsicGradientCurvatureCalculator(surface, step_size)
|
|
455
|
+
return calc.compute_gaussian_curvature(u, v)
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
def intrinsic_gradient_mean_curvature(
|
|
459
|
+
surface: Surface,
|
|
460
|
+
u: float,
|
|
461
|
+
v: float,
|
|
462
|
+
step_size: float = 1e-4
|
|
463
|
+
) -> float:
|
|
464
|
+
"""
|
|
465
|
+
Compute mean curvature using intrinsic gradient operator method (simplified interface)
|
|
466
|
+
|
|
467
|
+
Parameters:
|
|
468
|
+
surface: Surface object
|
|
469
|
+
u, v: parameter coordinates
|
|
470
|
+
step_size: finite difference step size (default: 1e-4)
|
|
471
|
+
|
|
472
|
+
Returns:
|
|
473
|
+
Mean curvature H
|
|
474
|
+
"""
|
|
475
|
+
calc = IntrinsicGradientCurvatureCalculator(surface, step_size)
|
|
476
|
+
return calc.compute_mean_curvature(u, v)
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
def intrinsic_gradient_principal_curvatures(
|
|
480
|
+
surface: Surface,
|
|
481
|
+
u: float,
|
|
482
|
+
v: float,
|
|
483
|
+
step_size: float = 1e-4
|
|
484
|
+
) -> Tuple[float, float]:
|
|
485
|
+
"""
|
|
486
|
+
Compute principal curvatures using intrinsic gradient operator method (simplified interface)
|
|
487
|
+
|
|
488
|
+
Parameters:
|
|
489
|
+
surface: Surface object
|
|
490
|
+
u, v: parameter coordinates
|
|
491
|
+
step_size: finite difference step size (default: 1e-4)
|
|
492
|
+
|
|
493
|
+
Returns:
|
|
494
|
+
Tuple of principal curvatures (k1, k2)
|
|
495
|
+
"""
|
|
496
|
+
calc = IntrinsicGradientCurvatureCalculator(surface, step_size)
|
|
497
|
+
return calc.compute_principal_curvatures(u, v)
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
def intrinsic_gradient_all_curvatures(
|
|
501
|
+
surface: Surface,
|
|
502
|
+
u: float,
|
|
503
|
+
v: float,
|
|
504
|
+
step_size: float = 1e-4
|
|
505
|
+
) -> Dict[str, Union[float, Tuple[float, float, float]]]:
|
|
506
|
+
"""
|
|
507
|
+
Compute all curvature quantities using intrinsic gradient operator method (simplified interface)
|
|
508
|
+
|
|
509
|
+
Parameters:
|
|
510
|
+
surface: Surface object
|
|
511
|
+
u, v: parameter coordinates
|
|
512
|
+
step_size: finite difference step size (default: 1e-4)
|
|
513
|
+
|
|
514
|
+
Returns:
|
|
515
|
+
Dictionary containing all curvature-related quantities
|
|
516
|
+
"""
|
|
517
|
+
calc = IntrinsicGradientCurvatureCalculator(surface, step_size)
|
|
518
|
+
return calc.compute_all_curvatures(u, v)
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
# ========== Exports ==========
|
|
522
|
+
|
|
523
|
+
__all__ = [
|
|
524
|
+
# Main classes
|
|
525
|
+
'IntrinsicGradientOperator',
|
|
526
|
+
'IntrinsicGradientCurvatureCalculator',
|
|
527
|
+
|
|
528
|
+
# Simplified interfaces
|
|
529
|
+
'intrinsic_gradient_gaussian_curvature',
|
|
530
|
+
'intrinsic_gradient_mean_curvature',
|
|
531
|
+
'intrinsic_gradient_principal_curvatures',
|
|
532
|
+
'intrinsic_gradient_all_curvatures',
|
|
533
|
+
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: coordinate_system
|
|
3
|
-
Version: 2.
|
|
4
|
-
Summary: High-performance 3D coordinate system library with
|
|
3
|
+
Version: 2.5.1
|
|
4
|
+
Summary: High-performance 3D coordinate system library with 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
|
|
@@ -9,7 +9,7 @@ License: MIT
|
|
|
9
9
|
Project-URL: Bug Reports, https://github.com/panguojun/Coordinate-System/issues
|
|
10
10
|
Project-URL: Source, https://github.com/panguojun/Coordinate-System
|
|
11
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 metric-tensor connection-operator discrete-geometry surface-curvature
|
|
12
|
+
Keywords: 3d math vector quaternion coordinate-system geometry graphics spatial-computing differential-geometry curvature metric-tensor connection-operator discrete-geometry surface-curvature intrinsic-gradient-operator
|
|
13
13
|
Platform: Windows
|
|
14
14
|
Platform: Linux
|
|
15
15
|
Platform: macOS
|
|
@@ -0,0 +1,11 @@
|
|
|
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,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
coordinate_system/__init__.py,sha256=S-h_uoibcICCh5Tk_-Q6_aMwiCQ2vvKUgE4BzqCHpJ0,7086
|
|
2
|
-
coordinate_system/coordinate_system.cp313-win_amd64.pyd,sha256=U-Qh2-MFB7aBMbPcipJSsQutvXqqowjTt7_46FdmZD4,494080
|
|
3
|
-
coordinate_system/curvature.py,sha256=o2XQ7BryvzEyo9cCYhKleeRg6UzacfShSeYyGQkGnwo,26040
|
|
4
|
-
coordinate_system/differential_geometry.py,sha256=yKn1pItaE-tepy-HAetkVfb-jRbDY7RKv68NKk4jsSQ,26345
|
|
5
|
-
coordinate_system/two_stage_curvature.py,sha256=e4fYAhiUc8NwtBi5hz5se4if4i8zZzG8smNlWNwuJpw,7219
|
|
6
|
-
coordinate_system-2.4.2.dist-info/LICENSE,sha256=tDnRkJxBYPzWdfh2gArRqrUPJxQZRZHJVs68qqBHIq4,1083
|
|
7
|
-
coordinate_system-2.4.2.dist-info/METADATA,sha256=wSFHcdSVfkoMobvyqHL4GaKpOrALzGYCDS5eJXOZjB0,19414
|
|
8
|
-
coordinate_system-2.4.2.dist-info/WHEEL,sha256=4-iQBlRoDdX1wfPofc7KLWa5Cys4eZSgXs6GVU8fKlQ,101
|
|
9
|
-
coordinate_system-2.4.2.dist-info/top_level.txt,sha256=R6LguuPPZ5esrIsDTqPGi9UxCvZPIXwn7KRKX87c79M,18
|
|
10
|
-
coordinate_system-2.4.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|