-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Numerically approximate arc perimeter #381
base: main
Are you sure you want to change the base?
Conversation
I've no idea about the math here, but what Raph and I had discussed (somewhat) for #378 is that I would fix the one part that is broken and it could land and then a follow up (like this one?) would replace the current math with better math for the |
This is based on top of your PR, changing The |
59540e4
to
c8fcd34
Compare
Simplified a bit and hopefully all edge cases are now correct.
|
I've optimized a bit, the implementation now requires three evaluations of the elliptic integrals, one of which is actually a complete integral and could be optimized with a quadratically converging approximation (which I suggest we leave for a later PR, that's also relevant for the |
This uses an approximation of the arc length using beziers as the analytic solution is quite involved.
Co-authored-by: Daniel McNab <[email protected]>
Also add some more tests
2bff820
to
5e722d3
Compare
5e722d3
to
920728b
Compare
This doesn't (or doesn't easily?) occur for ellipses, as they instead get a rotation when constructed with radius y > radius x.
This is on top of PR #378.
This implementation uses Carlson symmetric forms (https://arxiv.org/abs/math/9409227v1) of incomplete elliptical integrals of the second kind to numerically approximate elliptical arc lengths. These forms have nice computational properties allowing quick convergence of the approximations (each iteration reduces the error bound by 4⁶). Boost and Gnu Scientific Library are some other projects using them.
The error bounds don't seem quite correct yet. In theory, and if my understanding is correct, the Carlson approximations should be bounded in relative error by the given relative error param (i.e., if the approximation converges to some value
y
, the true value is withiny ± y*relative_error
. I'll have to dig into it some more.