Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm to "trace" sequential points into bezier curves

Tags:

I have a sequential collection of points in X,Y and I'd like to "trace" these into a set of bezier curves. Could any open source bitmap to vector tracing algorithm or library be used for this?

like image 677
Robin Rodricks Avatar asked Jul 22 '09 11:07

Robin Rodricks


2 Answers

This depends on what you want to accomplish. If you want to see the 'best fit' curve, or at least a rough approximation, you should use a b_spline. A b_spline will fit itself 'inside' the points it is given. For going through the points in question I would generally use a Catmull-Rom spline which, when given points 1,2,3 will pass through point 2 with slope equal to the slope between points 1 & 3.

Sample Code: http://willperone.net/Code/spline.php

Explanation of the algorithm: http://steve.hollasch.net/cgindex/curves/catmull-rom.html

like image 86
TJ Seabrooks Avatar answered Oct 11 '22 21:10

TJ Seabrooks


You want to use piece-wise b-spline curves rather than beziers if you want the curve to pass through an existing set of points.

There's tons of code on the web for doing this.

like image 45
U62 Avatar answered Oct 11 '22 23:10

U62