Skip to content

Commit 9cbf749

Browse files
committed
Clean up text and add html version
1 parent 67f36a3 commit 9cbf749

File tree

3 files changed

+45
-31
lines changed

3 files changed

+45
-31
lines changed

examples/NDLPwriteup.html

Lines changed: 19 additions & 0 deletions
Large diffs are not rendered by default.

examples/NDLPwriteup.jl

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@ md"""
1616
1717
## Motivation: Efficient one-shot curve sampling with tight deviation bounds
1818
19-
Many numerical methods require representing smooth curves by piecewise-linear segments. Examples include panel methods, filament methods, and boundary integral discretizations. The goal is typically to place points along a curve such that:
20-
- geometric error is controlled,
21-
- unnecessary points are avoided,
22-
- and refinement behaves predictably.
19+
Many numerical methods require representing smooth curves by points sampled along the curve. Examples include panel methods, filament methods, and boundary integral discretizations. The goal is typically to place points along a curve such that geometric error is controlled, unnecessary points are avoided, and refinement behaves predictably.
2320
24-
The most common approach in practice is recursive subdivision: split segments until local error criteria are satisfied. While robust, subdivision is inefficient in the number of segments required and highly sensitive to small changes in curve definition and segmentation parameters.
21+
The most common approach in practice is recursive subdivision which splits segments until local error criteria are satisfied. While robust, subdivision is prone to oversample points and is sensitive to small changes in curve and segmentation parameters.
2522
26-
The most common alternative is to construct a re-parameterization for the curve to heuristically control accuracy. These methods typically weight the arc-speed with local curvature in some manner, but such methods lack guarantees and must be tuned iteratively *for each case* to achieve any required error limit.
23+
The most common alternative is to construct a re-parameterization for the curve to heuristically control accuracy. Curvature-weighted reparameterizations produce smooth segmentations but offer no direct control over maximum deviation and therefore require iterative tuning.
2724
28-
In this notebook we explore an alternative: Normal-Deviation–Limited Parameterization (NDLP). NDLP hard-codes a pointwise geometric deviation bound directly into a parameterization using the curve's normal acceleration. We will show that the resulting segmentation has smoothly varying density and exhibits a maximum deviation from the curve which is tightly bound to a prescribed tolerance, enforcing the bound while minimizing the number of segments. This is achieved without iteration or heuristic tuning - a true one-shot method.
25+
In this notebook we propose Normal-Deviation–Limited Parameterization (NDLP) which embeds a pointwise geometric deviation bound in the parameterization using the curve's normal acceleration. The resulting segmentation has smoothly varying density and exhibits a maximum deviation from the curve which is tightly bound to a prescribed tolerance, enforcing the bound while minimizing the number of segments. This is achieved without iteration or heuristic tuning - a true one-shot method.
2926
30-
All results below are fully reproducible.
27+
All results below are fully reproducible. Click the "Download as Pluto notebook" button at the top right to run locally.
3128
3229
## Key idea
3330
@@ -43,7 +40,7 @@ where $\Delta s$ is the maximum segment length and $d_n$ is a specified normal d
4340
4441
## Illustration
4542
46-
We give an initial illustration of the the performance over the new approach using a cubic spline geometry and a coarse sampling $\Delta s=1/4$ and $d_n=9$% to highlight the differences. The new NDLP sampling is tight to the prescribed deviation limit and uses the fewest number of points.
43+
We give an initial illustration of the the performance over the new approach using a cubic spline geometry and a coarse sampling $\Delta s=1/4$ and $d_n=9\%$ to highlight the differences. The new NDLP sampling is tight to the prescribed deviation limit and uses the fewest number of points.
4744
"""
4845

4946
# ╔═╡ e1bc7e76-a497-41db-8f91-b8912e359e0e
@@ -58,7 +55,7 @@ We begin by defining a small set of representative curves:
5855
1. a three-dimensional helix with varying pitch and radius,
5956
1. and a V-shaped "curve" with a corner that violates smoothness assumptions.
6057
61-
These are deliberately chosen to expose both strengths and failure modes of the methods. The final example (the V-shape) is included as a negative control as local curvature-based methods can not handle curvature discontinuities gracefully.
58+
These are deliberately chosen to expose both strengths and failure modes of the methods. The final example (the V-shape) is included as a negative control as local curvature-based methods cannot handle curvature discontinuities gracefully.
6259
"""
6360

6461
# ╔═╡ 28abbec4-f1ea-4edb-8bd7-bcdc63c7cd82
@@ -107,11 +104,11 @@ We begin by defining three segmentation methods: 1. adaptive subdivision, 2. cur
107104
108105
The adaptive subdivision method recursively splits segments until local deviation and length criteria are met. For each segment $[u_i,u_{i+1}]$, we approximate the segment curve length $\Delta l$ and the maximum deviation $\delta$ by sampling points along the segment. If either limit is exceeded the segment is bisected at $u_m = (u_i + u_{i+1})/2$. This process continues until all segments satisfy the criteria.
109106
110-
The limitation of this method is that it is inherently binary: segments are either split or not based on local criteria. Therefore, any violation of the tolerance, no matter how small, forces a full bisection, resulting in up to 50% local oversampling. The discrete nature of the approach also makes the final segmentation sensitive to small changes in the curve are limits, adding discretization noise to methods using the segmentation, such as convergence and optimization studies.
107+
The limitation of this method is that it is inherently binary: segments are either split or not based on local criteria. Therefore, any violation of the tolerance, no matter how small, forces a full bisection, resulting in up to 50% local oversampling. The discrete nature of the approach also makes the final segmentation sensitive to small changes in the curve or limits, adding discretization noise to methods using the segmentation, such as convergence and optimization studies.
111108
112-
### 2. Curvature-weighted sampling
109+
### 2. Curvature weighted sampling
113110
114-
A common method to smoothly control the deviation is to reparameterize the curve with the local curvature $\kappa$ to increase sampling density in high-curvature regions. A simple choice is to define a reparameterized speed function $s' = l'\sqrt{1 + \tilde C \kappa}$, where $\tilde C$ is a tunable constant. This results in smooth segmentations, but there is no direct control over the maximum deviation from the curve, and the method requires iterative tuning of $\tilde C$ to achieve any required deviation limits.
111+
A common method to smoothly control the deviation is to reparameterize the curve with the local curvature $\kappa$ to increase sampling density in high-curvature regions. A simple choice is to define a reparameterized speed function $s' = l'\sqrt{1 + \tilde C \kappa}$, where $l' = \lVert r'(u) \rVert$ is the arc-speed and $\tilde C$ is a tunable constant. This results in smooth segmentations, but there is no direct control over the maximum deviation from the curve, and the method requires iterative tuning of $\tilde C$ to achieve any required deviation limits.
115112
116113
Note that the units of $\tilde C$ are length, so it is sensible to set $\tilde C = C \Delta s$ for some dimensionless $C$. However, this parameter still must be tuned and won't generalize across curves or sampling densities, as demonstrated here.
117114
@@ -123,8 +120,8 @@ Starting from the curvature-based deviation estimate $\delta\approx \frac 1 8 \D
123120
124121
$s' \geq l' \sqrt{\frac{\Delta s \kappa}{8d_n}}.$
125122
126-
Defining the geometric normal arc-acceleration $a_n = \sqrt{|r''|^2-l''^2} = l'^2 \kappa$, and
127-
demanding also that $s' \geq l'$ such that $\Delta l \leq \Delta s$ implies that the tightest speed parameterization to the two bounds is:
123+
Defining the curve's geometric normal acceleration $a_n \equiv \sqrt{\lVert r'' \rVert^2-l''^2} = l'^2 \kappa$, and
124+
demanding also that $s' \geq l'$ such that $\Delta l \leq \Delta s$ yields the speed parameterization which is tight to both limits:
128125
129126
$s' = \max\left(l', \sqrt{\frac{\Delta s a_n}{8 d_n}}\right)$
130127
@@ -137,15 +134,13 @@ Note that while the deviation estimate that is the basis of this parameterizatio
137134
md"""
138135
### Results
139136
140-
We evaluate each method on the test curves defined above, using a maximum segment length of $\Delta s=L/20$ and a deviation limit of $d_n=1/100$. The results are summarized in the tables below, reporting the following metrics:
141-
- `δ∞`=$\max(\delta)/(d_n\Delta s)$: the scaled normal deviation,
137+
We evaluate each method on the test curves defined above, using a maximum segment length of $\Delta s=L/33$ and a deviation limit of $d_n=1/100$. The results are summarized in the tables below, reporting the following metrics:
138+
- `δ∞`=$\max(\delta)/(d_n\Delta s)$: the scaled normal deviation (target is 1),
142139
- `σ`=$N\Delta s/L-1$: the scaled number of extra segments needed to hit the deviation limit (lower is better),
143140
- `Rₜᵥ`=$\sum(R)/L$ where $R_i=|Δl_{i+1}-Δl_i|$: the scaled total variation of segment lengths (lower is better),
144141
- `R∞`=$\max(R)/\Delta s$: the scaled maximum variation of segment lengths (lower is better).
145142
146-
The NDLP segmentation consistently produces a max deviation which is tight to the prescribed limit, resulting in with minimal excess segments, outperforming both adaptive subdivision and curvature-weighted sampling. In particular the measured deviation is within ±4% of the deviation limit, while the curvature weighted method has a ±15% variation **even after tuning**, and the subdivision method can be up to 50% oversampled.
147-
148-
Adjacent segment lengths under NDLP sampling differ by at most $O(\Delta s)$, indicating Lipschitz-continuous spacing adaptation with respect to arclength. Moreover, for fixed deviation limit, the parameterization converges to uniform arclength as $\Delta s\rightarrow 0$ by construction, so both the total variation and the maximum local spacing variation vanish under refinement.
143+
The NDLP segmentation consistently produces a max deviation which is tight to the prescribed limit, resulting in minimal excess segments, outperforming both adaptive subdivision and curvature-weighted sampling. In particular the deviation from NDLP sampling is within 4% of the deviation limit, while the curvature weighted method has a ±20% variation **even after tuning**, and the subdivision method can be up to 50% oversampled. Adjacent segment lengths under NDLP sampling differ by at most $O(\Delta s)$, indicating Lipschitz-continuous spacing adaptation with respect to arclength.
149144
"""
150145

151146
# ╔═╡ b38c2b1c-a48c-4f1f-954b-95faaba680d7
@@ -185,23 +180,23 @@ begin
185180
rseg = (u₀=um, u₁=s.u₁, dl=seg_len(r,um,s.u₁), δ=seg_dev(r,um,s.u₁))
186181
segments[i] = lseg; insert!(segments, i+1, rseg)
187182
end
188-
[getfield.(segments,:u₀);u₁]
183+
[map(s->s.u₀,segments); u₁]
189184
end
190185
function κ_weighted(r, u₀, u₁, Δs, dₙ)
191-
C = 11 # Hand tuned to work on the test_curves! 🤢
186+
C = 10.5 # Hand tuned for these test_curves! 🤢
192187
speed(u) = √(arcspeed(r)(u)^2+C*Δs*aₙ(r,u))
193188
S,s⁻¹ = ∫speed(speed, u₀, u₁)
194189
return s⁻¹.(range(0, S, round(Int,S/Δs)+1))
195190
end
196-
function NDLP(r, u₀, u₁, Δs, dₙ) # so nice 🤓
191+
function NDLP(r, u₀, u₁, Δs, dₙ) # one-shot sampling! 🤓
197192
speed(u) = max(arcspeed(r)(u),√(Δs*aₙ(r,u)/8dₙ))
198193
rtol = 1e-6Δs # only needed since convergence study lets Δs→0
199194
S,s⁻¹ = ∫speed(speed, u₀, u₁; rtol)
200195
return s⁻¹.(range(0, S, round(Int,S/Δs)+1))
201196
end
202-
function ∫speed(speed, u₀, u₁; rtol=1e-5,order=3)
197+
function ∫speed(speed, u₀, u₁; rtol=1e-5)
203198
# Adaptive speed(u) integration
204-
S,_,Δᵢ = quadgk_segbuf(speed,range(u₀, u₁,4);rtol,order) # approx is ok
199+
S,_,Δᵢ = quadgk_segbuf(speed,range(u₀, u₁,4);rtol,order=3) # approx is ok
205200
# Get values and derivatives
206201
sort!(Δᵢ,by=Δ->Δ.a)
207202
uᵢ,sᵢ = [u₀; map(Δ->Δ.b,Δᵢ)],[zero(S); cumsum(map(Δ->Δ.I,Δᵢ))]
@@ -224,7 +219,7 @@ plot(); let
224219
end; plot!(aspect_ratio=:equal,xlabel="x",ylabel="y")
225220
226221
# ╔═╡ 0394397a-1198-444b-9340-b3b737e1b638
227-
Δs = 1/20; dₙ = 1/100;
222+
Δs = 1/33; dₙ = 1/100;
228223
229224
# ╔═╡ f7a8cdf1-2cdb-4d6b-a10f-3f2d980c836e
230225
map(test_curves) do (name, r, range, _)
@@ -247,7 +242,7 @@ md"""
247242
248243
We also evaluate the convergence of the NDLP segmentation metrics as the $\Delta s$ and $d_n$ limits vary. We use the cubic spline fish as a representative curve.
249244
250-
Holding $d_n=1$% constant and *reducing* $\Delta s$ shows two distance phases.
245+
Holding $d_n=1\%$ constant and *reducing* $\Delta s$ shows two distance phases.
251246
- In the first phase, the deviation $\max(\delta)$ goes rapidly to the limit $d_n\Delta s$ and holds steady while the excess number of segments and total variation in the panel lengths drops to zero with $\Delta s$.
252247
- In the second phase the deviation limit is no longer active, so $\max(\delta)$ goes to zero without any additional segments or any length variation.
253248
"""
@@ -270,12 +265,12 @@ end
270265
# ╔═╡ 67eba604-640b-4388-bc08-928f4e5e62ca
271266
md"""
272267
Holding $\Delta s=L/100$ and _increasing_ $d_n$ shows a similar trend.
273-
- Again, in the first phase, the deviation limit is honored while the excess segments and total variation in segment lengths drop to zero. The key difference is that the $\max(R)$ remains roughly constant through this range; approximately $\Delta s/3$ for this example. Again, this indicates Lipschitz-continuous spacing, even for finite $\Delta s$ and large $d_n$.
268+
- Again, in the first phase, the deviation limit is honored while the excess segments and total variation in segment lengths drop to zero. The key difference is that the $\max(R)/\Delta s$ remains roughly constant through this range; approximately $1/3$ for this example. Again, this indicates Lipschitz-continuous spacing, even for finite $\Delta s$.
274269
- In the second phase, the $d_n$ limit deactivates, letting $\max(\delta)$ scaled by $d_n$ and $\max(R)$ both drop to zero as the sampling becomes uniformly spaced.
275270
"""
276271
277272
# ╔═╡ 260406ec-97ff-49fc-bb17-4f28fe12b8b6
278-
convergedₙ = map(logrange(1,6e-4,70)) do dₙ
273+
convergedₙ = map(logrange(1,5e-4,100)) do dₙ
279274
(;dₙ,metrics(NDLP,test_curves[3].r,test_curves[3].range...,1e-2,dₙ)...)
280275
end |> Table;
281276
@@ -1796,7 +1791,7 @@ version = "1.13.0+0"
17961791
# ╟─28abbec4-f1ea-4edb-8bd7-bcdc63c7cd82
17971792
# ╟─957d0951-2070-4d64-8fc9-58b5121bdfc1
17981793
# ╟─10b2e0b0-f373-4a02-b6dc-fd1085b1f34a
1799-
# ╠═cc1fa09e-21da-425d-bb6c-a8c906a65e98
1794+
# ╟─cc1fa09e-21da-425d-bb6c-a8c906a65e98
18001795
# ╟─219826fb-5362-46f2-bf51-84465e614269
18011796
# ╠═b38c2b1c-a48c-4f1f-954b-95faaba680d7
18021797
# ╠═0394397a-1198-444b-9340-b3b737e1b638

src/panels.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ by integrating the pseudo-arcspeed `s' = max(l',√(Δs*aₙ/8devlimit)))` where
7171
7272
The speed `s'` is defined such that segments of length `Δs` along `r`
7373
deviate no more than `δ≤Δs*devlimit` from the curve. Starting from the
74-
curvature-based deviation estimate `δ≈Δl²/8κ`, and using `Δl≈l'*Δu`
74+
curvature-based deviation estimate `δ≈Δl²κ/8`, and using `Δl≈l'*Δu`
7575
and `Δs≈s'*Δu` gives the inequality `s'≥l'√(Δs*κ/8devlimit)`. Demanding also
7676
that `s'≥l'` such that `Δl≤Δs` and substituting `aₙ = l'² κ` leads to
7777
the rate equation above.

0 commit comments

Comments
 (0)