views:

112

answers:

2

Given the following path: alt text

How could these smooth curves be generated given that the user provides the points and that cubic bezier is used? How would the control points or bezier handles be solved for, or how could I compute these points using cubic bezier given the user points above (the red squares) ? Basically I have an algorithm to solve for a cubic bezier curve given 4 points but the user only provides the points below so there are no control points, how do I obtain these?

Thanks

+3  A: 

Look up Catmull-Rom splines. Here's an introduction.

Further reading:

Chris Dennett
But this does not give me a way to solve for the 4 points, I want to solve for the bezier handles, not use a different algorithm since the rest of my application uses cubic bezier
Milo
Oh, this is basically Catmull-Rom to Bezier then. Some discussion is here: http://processing.org/discourse/yabb2/YaBB.pl?num=1212123950
Chris Dennett
How do you handle cases where the whole path is less than 4 points or not a multiple of 4?
Milo
As long as you have properly-defined catmull-rom control points (you only need a few and it works, your example has around 16, I haven't counted), you can always convert to bezier control points (as per the example in the comment), or am I missing something? :)
Chris Dennett
Would it look decent if instead of this I simply used cubic bezier where P0 is the first point, P1 is the second etc..., this would effectivly divide my number of points by 2...
Milo