Sign in to follow this  
BeanDog

Building a smooth set of parametric curves from a sorted list of points in a plane

Recommended Posts

BeanDog    1065
I want to let my users freehand draw curves, and then replace what they drew with a smooth approximation by a series of parametric curves (splines). Whatever method I choose, I'd like to be able to adjust the threshold of how closely the curves need to match the original data. That is, I'd like to play with representing their input as just a few large curves vs. many smaller curves that match it more closely. I see this happen in many vector drawing applications, so I feel like this is a pretty solved problem. Some quick Googling on fitting splines to arbitrary points turned up some information, but basically all of it assumes that you're fitting splines to a small number of points. I'm fitting splines to a very large number of points, not all of which probably need to contribute to the end result. Any pointers? Or functions ready to go? [smile]

Share this post


Link to post
Share on other sites
Dave Eberly    1173
Take a look at BSplineCurveFitter, which uses a least-squares fitting algorithm. The application is set up for 3D, so you can set z = 0 for all the input points or replace the Vector3 by Vector2 in the code. You get to select how many control points you want, say, as a percentage of the total number of input samples. It does not matter how large the number of samples.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this