Skip to content
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

Simplifying Bézier paths #95

Merged
merged 3 commits into from
Apr 19, 2023
Merged

Simplifying Bézier paths #95

merged 3 commits into from
Apr 19, 2023

Conversation

raphlinus
Copy link
Owner

First draft of new blog post.

Closes #94

First draft of new blog post.

Closes #94
Copy link

@Julian-Wollersberger Julian-Wollersberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice article!


Two implementations are provided: parallel curves of cubic Béziers, and arbitrary Bézier paths for simplification. Implementing the trait is not very difficult, so it should be possible to add more source curves and transformations, taking advantage of powerful, general mechanisms to compute an optimized Bézier path.

The core cubic Bézier fitting algorithm is based on measuring the area and moment of the source code. A default implementation is provided by the `ParamCurveFit` trait implementing numerical integration based on derivatives (Green's theorem), but if there's a better way to compute area and moment, source curves can provide their own implementation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The core cubic Bézier fitting algorithm is based on measuring the area and moment of the source code. A default implementation is provided by the `ParamCurveFit` trait implementing numerical integration based on derivatives (Green's theorem), but if there's a better way to compute area and moment, source curves can provide their own implementation.
The core cubic Bézier fitting algorithm is based on measuring the area and moment of the source curve. A default implementation is provided by the `ParamCurveFit` trait implementing numerical integration based on derivatives (Green's theorem), but if there's a better way to compute area and moment, source curves can provide their own implementation.


![Arc length parametrization is much more accurate](/assets/simplify-arc.svg)

However, arc length parametrization is considerably slower (about a factor of 10) because it requires inverse arc length computations. The current approach is to classify whether the source curve is "spicy" (considering the deltas between successive normal angles) and use the more robust computation only in those cases.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
However, arc length parametrization is considerably slower (about a factor of 10) because it requires inverse arc length computations. The current approach is to classify whether the source curve is "spicy" (considering the deltas between successive normal angles) and use the more robust computation only in those cases.
However, arc length parametrization is considerably slower (about a factor of 10) because it requires inverse arc length computations. My current approach is to classify whether the source curve is "spicy" (considering the deltas between successive normal angles) and use the more robust computation only in those cases.

It wasn't clear to me what is actually implemented now.

@raphlinus raphlinus merged commit bdf10bd into master Apr 19, 2023
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.

Bézier path simplification
2 participants