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

Bezier curve through points. #12

Open
be5invis opened this issue Jul 17, 2015 · 6 comments
Open

Bezier curve through points. #12

be5invis opened this issue Jul 17, 2015 · 6 comments

Comments

@be5invis
Copy link

A function constructs quadratic/cubic/poly bezier curve through points given would be useful.
Nicer if we can specify tangent direction of start and end points.

@Pomax
Copy link
Owner

Pomax commented Jul 17, 2015

Good point, I forgot I hadn't ported Catmull-Rom to bezier.js yet.

@soswow
Copy link

soswow commented Jul 26, 2015

@Pomax just in case this might be useful https://github.com/soswow/fit-curves

@Pomax
Copy link
Owner

Pomax commented Jul 26, 2015

no really need (although thanks for the suggestion): they're already written up in http://pomax.github.io/bezierinfo/#catmullconv, just haven't had time to move them into bezier.js, too. https://github.com/Pomax/bezierjs/tree/gh-pages/test/autodraw makes use of the concept already, but in its own file. We're not working with rational B-splines, but plain Bezier curves, so we can just do a straight up Catmull-Rom fit and then trivially convert so that each segment uses Bezier instead of CR coordinates.

@lehni
Copy link

lehni commented Feb 9, 2016

I think you're talking of different types of curve-fitting here: @soswow's link is to a port of Philip J. Schneider's algorithm that tries to put as few curves as possible through a list of points with an allowed maximum error. We have this same algorithm in Paper.js too (with some added tweaks), exposed through Path#simplify(): https://github.com/paperjs/paper.js/blob/develop/src/path/PathFitter.js
You can see the code in action here: http://paperjs.org/examples/path-simplification/

The fitting of catmull-rom splines is what we offer under Path#smooth(): It creates a smooth path by adjusting the handles of the curves using different methods (catmull-rom being one of them), but without changing the amounts of segments / curves in a path.

Both approaches are useful in different situations, e.g. curve-fitting can be used to process the point data received from a pointing device.

@Pomax
Copy link
Owner

Pomax commented Feb 9, 2016

my bad, thanks for the correction.

@Pomax Pomax reopened this Feb 9, 2016
@behdad
Copy link

behdad commented Feb 10, 2016

I think you're talking of different types of curve-fitting here: @soswow's link is to a port of Philip J. Schneider's algorithm that tries to put as few curves as possible through a list of points with an allowed maximum error. We have this same algorithm in Paper.js too (with some added tweaks), exposed through Path#simplify(): https://github.com/paperjs/paper.js/blob/develop/src/path/PathFitter.js
You can see the code in action here: http://paperjs.org/examples/path-simplification/

Simplifying is in #26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants