views:

62

answers:

1

Right now i'm creating polygons with bezier handles. It's working well, except right now I always do something like this:

for(float i = 0; i < 1; i += 0.04)
{
   interpolate A, a.handle to B.handle, B at time i
}

The problem is no matter how short the distance or long the distance between point A and B, it always produces the same amount of points. How could I do it so it always looks good but only interpolates as much as it has to. Ex: if Distance(A,B) is 40, then it may only subdivide like 15 times but then if Distance(A,B) is 20 it may only subdivide 7 times etc. How could I do this as a function of quality ex:

float GetThreshold(float distance, float quality)
{
}

Or something like that. Thanks

+3  A: 

What you probably want to investigate is an adaptive stepping algorithm.

The basic concept is that you want more points where the radius of curvature is small (i.e.- sharp bends), and fewer points where the radius of curvature is large (i.e.- more straight).

There is a great article here, that shows a good adaptive stepping algorithm. I used it a couple of years ago for some bezier curve work I was doing.

MarkD