[cairo] Algorithm help please!

Jonathan Morton jonathan.morton at movial.com
Fri May 8 05:46:17 PDT 2009

On Fri, 2009-05-08 at 14:31 +0200, Donn wrote:
> Gerdus,
> I see that the total distance of the path is quite important. I am not much 
> good at math, but I can't see how adding the x and y (along the path list) 
> together can give the total distance. It seems it should be more of a triggy 
> kind of Pythagoras affair. I will hit google with 'length path algorithm' in 
> a mo.

Adding the delta-x and delta-y would give you what is known as the
"Manhattan distance", which is a fair approximation to the Euclidean
distance (which is what Pythagoras gives you).  The big advantage of
such an approximation is speed.

If speed is not very important, by all means use Pythagoras, just watch
out for those slow square roots.

From: Jonathan Morton
      jonathan.morton at movial.com

More information about the cairo mailing list