[cairo] adding a new curve type to cairo

Bill Spitzak spitzak at d2.com
Wed Jul 12 10:38:59 PDT 2006


Cubic splines can be drawn with the curve-to operator, which draws a 
cubic Bezier curve.

For each of your segments, you can figure out the 4 control points:

The first and last points are the end points of the segment.

The intermediate points are at 1/3 and 2/3 the distance horizontally 
between the control points, and their vertical position is such that the 
slope is equal to the value at the control point.

For a segment between x0 and x3, with a cubic function y=f(x) with 
derivative f'(x), the points are (I think, check this!):

x0, f(x0)

(2x0+x3)/3, f(x0)+f'(x0)*(x3-x0)/3

(x0+2x3)/3, f(x3)-f'(x3)*(x3-x0)/3

x3, f(x3)

Incidentally, interesting paper. I was doing the same thing but in a 
non-mathematical way, I was just forcing the derivative to zero when the 
slopes on each side were either zero of had different signs. This would 
seem to more cleanly put it into cubic interpolation.

Paul Davis wrote:
> greetings. the ardour project (http://ardour.org/ its a digital audio
> workstation) is looking ahead just a little towards our move onto a
> Cairo-based canvas for our editor. 
> 
> one of our interests is in getting "native" support from the graphics
> library for a rather unique type of constrained spline that we use. at
> the moment, we never draw these curves because (a) libart_lgpl does not
> support them and (b) we would want them anti-aliased, which looks more
> complex than any of our developers has wanted to tackle so far. instead,
> we just draw straight line segments through the control points for the
> splines.
> 
> the constrained spline is a brilliant little piece of work by a chemical
> engineer from the UK. unlike regular splines, the curve never goes above
> or below the control points, which makes it more useful for engineering
> applications than regular splines. a paper on it can be found here:
> 
> 	http://www.korf.co.uk/spline.pdf


More information about the cairo mailing list