analytics

Saturday, July 13, 2013

Constructing a smooth curve from a set of points geometrically

Suppose you start with a set of points and you know the order they should be connected...
The first step of this method is to construct arcs between each set of 3 consecutive points in the geometrical sense.  Here I've done the first 3 points...
Doing each set of 3 consecutive points gives...


Now the next step is to place new points in the centroids of any enclosed areas like so...
Now all the arcs currently drawn can be deleted...
And the process reiterates... more arcs are drawn for every 3 consecutive points...
And then once again a point is placed for each centroid, and more arcs are drawn, here is where we are after 3 iterations...
As you can see the overall path becomes smoother and smoother. 
It can go on forever or a certain number of iterations. 

**EDIT**
Ofnuts from the gimp forum asked me a good question about how many iterations would be necessary... On a computer screen with pixels you would need to go log_2(pixel arc length) iterations.  The pixel arc length is the number of pixels in the final curve. An upper bound for the pixel arc length is the pixel length of the circular arcs placed in the first iteration.This is because the number of pixels you have placed doubles each iteration and the final curve fits inside of the first iterations arcs.  

2 comments:

  1. Is the final result different from a bezier curve for a same set of points ? Could you show the difference on the example situation ?

    ReplyDelete
  2. Hi thanks for the question, I might look into that some more tomorrow I'm about to go to bed. But maybe someone can correct me if I'm wrong I'm not an expert on Bezier curves but my understanding is the main problem with them is that computing them goes up exponentially with the number of points, and so they do separate smaller Bezier curves for each say, three points but then there's a problem with them not fitting smoothly together. Also I know when I'm working with them in inkscape you have to guide control points to match with the shape you want and it's kind of hard to match a series of them to the shape you want. But anyway maybe I'll do another blog post examining that issue. Thanks!

    ReplyDelete