Skip to content

Fix B-spline curvature and preserve finite-scale paths - #1459

Draft
Afloat16 wants to merge 1 commit into
AtsushiSakai:masterfrom
Afloat16:fix/bspline-stable-curvature
Draft

Afloat16 wants to merge 1 commit into
AtsushiSakai:masterfrom
Afloat16:fix/bspline-stable-curvature

Conversation

@Afloat16

@Afloat16 Afloat16 commented Oct 9, 2026

Copy link
Copy Markdown

Reference issue

The B-spline curvature formula was introduced in #720. Current B-spline and spline-curvature searches found no existing repair; the older cubic-spline issue #64 concerns a separate implementation.

What does this implement/fix?

The shared B-spline evaluator raises squared tangent length to 2/3 instead of 3/2. Returned curvature depends on parameter speed and has incorrect physical units. For the exact parabola x(u)=u, y(u)=u², curvature at u=1 is currently 0.683990 instead of the analytic 0.178885. Doubling a public interpolation path multiplies curvature by 1.587401; it should halve it.

Evaluate signed planar curvature using hypot for tangent length, a normalized tangent, and successive divisions by its length. This is algebraically (x′y″−y′x″)/(x′²+y′²)^(3/2) while avoiding cubed-length underflow for a finite straight path scaled by 1e-110. Public positions and headings are preserved. Both public docstrings now describe inverse-position units, and the existing official B-spline page explains the equation, sign, scale invariance and undefined zero-tangent case.

Regressions use closed-form positive and negative parabolas at three parameter speeds, interpolation and smoothing at degrees 2–5 under two spatial scales, and straight-path controls. Additional straight and signed-parabola cases cover finite coordinate scales 1e-110 and 1e110.

Additional information

  • Exact base: cdd0cc888802b584c2d654ca85e3c5460973487d.
  • Linux/Python 3.14.8 with the repository's exact pinned test requirements: identical B-spline tests give 26 failures and 9 controls on the base, then 35 passes on this patch under -Werror.
  • Complete required bash runtests.sh: 188 passed, including the actual changed-file Ruff and all nine configured mypy scopes. No skip or deselection was added.
  • Ruff on the two changed Python files and git diff --check pass.
  • The default example runs with the Agg backend; both approximation and interpolation plots were generated and visually inspected.
  • CircleCI-style strict make html passes on Python 3.13.16 with the exact project and documentation requirements. The exact-base documentation build also passed. Generated equation markup, both function source links, local images and parent navigation were checked.
  • Rendered HTML pixel QA is pending the official PR documentation artifact. This remains a draft while the documented ci/circleci: build_doc / artifact stage runs and its changed page can be inspected. Local HTML rendering was unavailable, and no browser-security, file-protocol or hosting workaround was used. A successful build is not claimed as rendered-page QA.
  • Windows/macOS, upstream CI and physical robots were not tested locally. Curvature remains undefined at a zero tangent.

AI assistance: prepared with OpenAI Codex (gpt-6.1-sol). The native validation above was executed in the current environment.

CheckList

  • Did you add an unittest for your new example or defect fix?
  • Did you add documents for your new example? The existing official B-spline page and public docstrings were updated; rendered HTML QA is pending the official artifact.
  • All CIs are green? Draft CI and official artifact QA remain pending.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant