<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div dir="ltr" id="yui_3_16_0_1_1427220891716_54200">Ah, that turns out to be quite understandable, it's a long time since I did any C, but will give it a go.<br></div><div id="yui_3_16_0_1_1427220891716_56792"><br></div><div id="yui_3_16_0_1_1427220891716_55570"> <br></div><div id="yui_3_16_0_1_1427220891716_47552"><div id="yui_3_16_0_1_1427220891716_47551">S++</div></div>  <br><div class="qtdSeparateBR"><br><br></div><div style="display: block;" class="yahoo_quoted"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"> <font face="Arial" size="2"> On Wednesday, March 25, 2015 2:27 AM, Krzysztof KosiƄski <tweenk.pl@gmail.com> wrote:<br> </font> </div> <blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;">  <br><br> <div class="y_msg_container">2015-03-24 20:16 GMT+01:00 Behdad Esfahbod <<a shape="rect" ymailto="mailto:behdad.esfahbod@gmail.com" href="mailto:behdad.esfahbod@gmail.com">behdad.esfahbod@gmail.com</a>>:<div class="yqt0332560344" id="yqtfd68778"><br clear="none">> On 15-03-24 01:45 PM, Bryce Harrington wrote:<br clear="none">>> On Tue, Mar 24, 2015 at 05:09:50PM +0000, Stuart Axon wrote:<br clear="none">>>> Is the best way to get the length of a cairo path to call cairo_copy_path_flat and sum the lengths of the LINE_TOs contained inside ?<br clear="none">><br clear="none">> That's what I've personally done in the past.  However:<br clear="none">><br clear="none">>>> I've been looking at arc lengths and it seems it can get complex,<br clear="none">><br clear="none">> There are very decent and simple approximations that I think are good enough<br clear="none">> for most purposes.  Read here for example:<br clear="none">><br clear="none">>   <a shape="rect" href="http://pomax.github.io/bezierinfo/#arclength" target="_blank">http://pomax.github.io/bezierinfo/#arclength</a><br clear="none">><br clear="none">> Would be interesting to measure or calculate the error of that approximation<br clear="none">> for small values of n.</div><br clear="none"><br clear="none">Numeric integration from the definition of arc length is an absurdly<br clear="none">complicated solution for the case of Beziers.<br clear="none"><br clear="none">Instead, you can exploit the trivial geometric fact that a Bezier<br clear="none">curve is longer than the polyline joining its control points, but<br clear="none">shorter than the distance between its endpoints. If the difference<br clear="none">between those is higher that the precision, do recursive Casteljau<br clear="none">subdivision and repeat on the parts.<br clear="none"><br clear="none">Here is a simple implementation with comments:<br clear="none"><a shape="rect" href="http://bazaar.launchpad.net/~lib2geom-hackers/lib2geom/trunk/view/head:/src/2geom/bezier-curve.cpp#L274" target="_blank">http://bazaar.launchpad.net/~lib2geom-hackers/lib2geom/trunk/view/head:/src/2geom/bezier-curve.cpp#L274</a><br clear="none"><br clear="none">Regards, Krzysztof<div class="yqt0332560344" id="yqtfd80499"><br clear="none"></div><br><br></div> </blockquote>  </div> </div>   </div></div></body></html>