<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Arial; font-size: 10pt; color: #000000'>Thanks for the answers.<br><br>I simply added more points and used cairo_line_to instead. It was sufficient for me and it made things a lot easier. <br><br>Indy<br><font size="1"><span style="color: rgb(0, 153, 0);"></span></font><span name="x"></span><br><hr id="zwchr"><div style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Dov Grobgeld" &lt;dov.grobgeld@gmail.com&gt;<br><b>To: </b>"Andrea Canciani" &lt;ranma42@gmail.com&gt;<br><b>Cc: </b>"cairo list" &lt;cairo@cairographics.org&gt;<br><b>Sent: </b>Tuesday, 15 November, 2011 11:10:08 AM<br><b>Subject: </b>Re: [cairo] Fwd: Bezier curve<br><br><div dir="ltr"><font face="courier new,monospace"><font face="arial,helvetica,sans-serif">If you really want to get into the mathematics of how to choose the control point in order to get an optimal approximation of a quarter of a circle, then you should have a look at the MetaFont source code by Donal Knuth. See: <a href="http://www.tex.ac.uk/ctan/systems/knuth/dist/mf/mf.web" target="_blank">http://www.tex.ac.uk/ctan/systems/knuth/dist/mf/mf.web</a> . <br>
<br>But if you want simply want to do calculations like this it might be easier to use  Asymptote <a href="http://asymptote.sourceforge.net/" target="_blank">http://asymptote.sourceforge.net/</a> , which is an evolution of MetaFont (via MetaPost). With Asymptote you can create paths by specifying with directions and tension, and it will calculate the control points for you. <br>
<br>Hope this helps.<br><br>Regards,<br>Dov<br></font></font><br><div class="gmail_quote">On Tue, Nov 15, 2011 at 11:43, Andrea Canciani <span dir="ltr">&lt;<a href="mailto:ranma42@gmail.com" target="_blank">ranma42@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">(I forgot to write to the list... sorry for the double mail)<br>
<br>
<br>
---------- Forwarded message ----------<br>
From: Andrea Canciani &lt;<a href="mailto:ranma42@gmail.com" target="_blank">ranma42@gmail.com</a>&gt;<br>
Date: Tue, Nov 15, 2011 at 10:42 AM<br>
Subject: Re: [cairo] Bezier curve<br>
To: Inderjit Singh &lt;<a href="mailto:inderjit.singh@spaceapplications.com" target="_blank">inderjit.singh@spaceapplications.com</a>&gt;<br>
<div class="im"><br>
<br>
On Mon, Nov 7, 2011 at 3:42 PM, Inderjit Singh<br>
&lt;<a href="mailto:inderjit.singh@spaceapplications.com" target="_blank">inderjit.singh@spaceapplications.com</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I'm new to cairo and I'm trying to draw a smooth curve between using an<br>
&gt; array of points.<br>
&gt;<br>
&gt; Say I have an array with (x,y) coordinates as: POS_T pos = {{0.0, 0.0},<br>
&gt; {1.0,1.0}, {1.5, 2.0}, {0.5, 3.0}, {0.0, 4.0}};<br>
&gt;<br>
&gt; So basically, a half round 'circle'. I've been looking in cairo docs but the<br>
&gt; closest thing I get to is the cairo_curve_to but for that it requires<br>
&gt; control points. How is it determined? I want a simple smooth line but using<br>
&gt; Bezier algorithm requires additional data to make it happen. Is that<br>
&gt; correct?<br>
<br>
</div>Yes, the additional data determines how the smoothing between the<br>
points is performed.<br>
You can choose the control points and get different smoothing types<br>
between your points.<br>
You might want to read something about splines (cairo supports cubic<br>
Bezier curves, which in turn can represent any parametric cubic<br>
curve).<br>
You can find an algorithm for cubic spline interpolation here<br>
<a href="http://en.wikipedia.org/wiki/Spline_interpolation" target="_blank">http://en.wikipedia.org/wiki/Spline_interpolation</a><br>
(I didn't test it).<br>
<div class="im"><br>
<br>
&gt;<br>
&gt; Or can I simply use curve_line_to and then interpolate this? currently the<br>
&gt; code looks like this for line:<br>
<br>
</div>cairo_line_to() would connect the points with straight line segments.<br>
<div class="im"><br>
&gt;<br>
&gt; ...<br>
&gt; &nbsp; &nbsp; for(uint32_t i = 0; i &lt; boundary; i=i++)<br>
&gt; &nbsp;&nbsp;&nbsp; {<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_move_to(cr, station-&gt;coverage[i].x, station-&gt;coverage[i].y);<br>
&gt;<br>
&gt; // &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_line_to(cr,<br>
&gt; // &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; station-&gt;coverage[(i+1) % boundary].x,<br>
&gt; // &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; station-&gt;coverage[(i+1) % boundary].y);<br>
&gt;<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cairo_curve_to(cr,<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; station-&gt;coverage[i].x,<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; station-&gt;coverage[(i].y,<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; station-&gt;coverage[i+1].x,<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; station-&gt;coverage[i+1].y,<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; station-&gt;coverage[i+2].x,<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; station-&gt;coverage[i+2].y);<br>
&gt; &nbsp;&nbsp;&nbsp; }<br>
&gt;<br>
&gt; &nbsp;&nbsp;&nbsp; cairo_set_line_width (cr, 1.5);<br>
&gt; &nbsp;&nbsp;&nbsp; cairo_stroke(cr);<br>
&gt;<br>
&gt; &nbsp;&nbsp;&nbsp; cairo_destroy(cr);<br>
&gt;<br>
&gt;<br>
&gt; Any help would be appreciated. Thanks.<br>
&gt; Indy<br>
<br>
</div>If you need further information, just write ;)<br>
<br>
Andrea<br>
<br>
&gt;<br>
<span class="HOEnZb"><font color="#888888">&gt;<br>
&gt; --<br>
&gt; cairo mailing list<br>
&gt; <a href="mailto:cairo@cairographics.org" target="_blank">cairo@cairographics.org</a><br>
&gt; <a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br>
&gt;<br>
--<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org" target="_blank">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br>
</font></span></blockquote></div><br></div>
<br>--<br>cairo mailing list<br>cairo@cairographics.org<br>http://lists.cairographics.org/mailman/listinfo/cairo</div><br></div></body></html>