<div class="gmail_quote">Hi - thanks as always to the tremendous team responsible for Cairo - it's an excellent library.<br><br>Does anyone have any experience rendering open, cubic uniform B-Splines using Cairo? I know that it does not have explicit support for B-Splines, but my understanding is that one can derive the series of Bézier splines represented implicity in a B-Spline. In fact I have code that does this for the open & periodic cases for quadratic b-splines, as well as the periodic case for cubic B-Splines. For that, my code looks about like this:<br>
<br>Vec2f q0, q1, q2, q3;<br>q0 = ( spline.getControlPoint( 0 ) + spline.getControlPoint( 1 ) * 4.0f + spline.getControlPoint( 2 ) ) / 6.0f;<br>moveTo( q0 );<br>int lastPt = ( spline.isLoop() ) ? numPoints : numPoints - 3;<br>
for( int i = 0; i < lastPt; ++i ) {<br> Vec2f p1 = spline.getControlPoint( ( i + 1 ) % numPoints );<br> Vec2f p2 = spline.getControlPoint( ( i + 2 ) % numPoints );<br> Vec2f p3 = spline.getControlPoint( ( i + 3 ) % numPoints );<br>
<br> q1 = p1 * ( 4.0f / 6.0f ) + p2 * ( 2.0f / 6.0f );<br> q2 = p1 * ( 2.0f / 6.0f ) + p2 * ( 4.0f / 6.0f );<br> q3 = p1 * ( 1.0f / 6.0f ) + p2 * ( 4.0f / 6.0f ) + p3 * ( 1.0f / 6.0f );<br> curveTo( q1, q2, q3 );<br>
}<br><br>The trouble comes when I try to address the open cubic case (where the curve passes through the endpoints of the b-spline). All of the literature on the topic which I can actually understand seems to be about the periodic case.<br>
<br>I know that in the open case, a b-spline with 4 control points exactly maps to the bezier curve with the same control points. Also through experimentation I can tell that the non-end segments of an open b-spline with >= 6 points correspond to the periodic case. However I am still at a loss as to how one would glue all of this information together, and I haven't managed to get deep enough in the relevant math to follow discussions of how knot insertion or blossoming helps me solve this problem.<br>
<br>Any help from someone experienced in all of this would be *very* much appreciated.<br><br>Thanks in advance...<br>
</div><br>