You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/NDLPwriteup.jl
+47-61Lines changed: 47 additions & 61 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ The most common alternative is to construct a re-parameterization for the curve
24
24
25
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.
26
26
27
-
All results below are fully reproducible. Click the "Download as Pluto notebook" button at the top right to run locally.
27
+
> All results below are fully reproducible. Click the `Edit or run this notebook` button at the top right.
28
28
29
29
## Key idea
30
30
@@ -62,7 +62,7 @@ These are deliberately chosen to expose both strengths and failure modes of the
@@ -132,27 +130,28 @@ Note that while the deviation estimate that is the basis of this parameterizatio
132
130
133
131
# ╔═╡ 219826fb-5362-46f2-bf51-84465e614269
134
132
md"""
135
-
### Results
133
+
## Method evaluation results
136
134
137
135
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
136
- `δ∞`=$\max(\delta)/(d_n\Delta s)$: the scaled normal deviation (target is 1),
139
137
- `σ`=$N\Delta s/L-1$: the scaled number of extra segments needed to hit the deviation limit (lower is better),
140
138
- `Rₜᵥ`=$\sum(R)/L$ where $R_i=|Δl_{i+1}-Δl_i|$: the scaled total variation of segment lengths (lower is better),
141
139
- `R∞`=$\max(R)/\Delta s$: the scaled maximum variation of segment lengths (lower is better).
142
140
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.
141
+
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.
144
142
"""
145
143
146
144
# ╔═╡ b38c2b1c-a48c-4f1f-954b-95faaba680d7
147
-
begin# sample `r` using `method`, and report metrics
145
+
begin
148
146
function metrics(method, r, u₀, u₁, Δs, dₙ)
149
-
L = quadgk(arcspeed(r), u₀, u₁)[1]; Δs *= L
150
-
u = method(r, u₀, u₁, Δs, dₙ)
151
-
dl,δ = seg_len(r,u),seg_dev(r,u)
152
-
(;δ∞ = maximum(δ)/(Δs*dₙ), # scaled max deviation, should => 1!
153
-
σ = length(δ)*Δs/L-1, # extra segments needed to hit dₙ
154
-
Rₜᵥ = sum(abs,diff(dl))/L, # total variation of segment length
155
-
R∞ = maximum(abs,diff(dl))/Δs) # max variation of segment length
147
+
L = seg_len(r, u₀, u₁) # total length of curve `r`
148
+
Δs *= L # scale by L to compare across curves
149
+
u = method(r, u₀, u₁, Δs, dₙ) # sample points using `method`
150
+
dl,δ = seg_len(r,u),seg_dev(r,u) # segment lengths and deviations
151
+
return (;δ∞ = maximum(δ)/(Δs*dₙ), # scaled max deviation, should => 1!
152
+
σ = length(δ)*Δs/L-1, # extra segments needed to hit dₙ
153
+
Rₜᵥ = sum(abs, diff(dl))/L, # total variation of segment length
154
+
R∞ = maximum(abs, diff(dl))/Δs) # max variation of segment length
156
155
end
157
156
158
157
# segment metrics
@@ -210,31 +209,26 @@ end
210
209
211
210
# ╔═╡ 60fc45b3-8cea-4cae-83f4-9c05011b1dee
212
211
plot(); let
213
-
c = test_curves[3]; x(u) = c.r(u)[1]; y(u) = c.r(u)[2]
214
-
for f in (κ_weighted,subdivision,NDLP)
215
-
u = f(c.r,c.range...,1/4,0.09)
216
-
δ = maximum(seg_dev(c.r,u))
217
-
plot!(x.(u),y.(u),label="$f, N=$(length(u)), max dev=$(round(δ,sigdigits=2))",marker=:circle)
plot!(title="NDLP segmentation metrics with fixed dₙ=1%")
255
+
plot!(title="NDLP segmentation metrics with fixed dₙ=$dₙ")
263
256
end
264
257
265
258
# ╔═╡ 67eba604-640b-4388-bc08-928f4e5e62ca
@@ -269,19 +262,18 @@ Holding $\Delta s=L/100$ and _increasing_ $d_n$ shows a similar trend.
269
262
- 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.
0 commit comments