[OSM-dev] Algorithm help

SteveC steve at asklater.com
Thu May 29 09:07:22 BST 2008

if the polygon is p1,p2,p3,p4...

c = centre point of polygon

v1 = the vector from c to p1 (p1 - c)
v2 = the vector from c to p2 (p2 - c)

take the cross product of v1 and v2


if its positive in the z axis its one way, if its negative its the other

On 28 May 2008, at 21:26, Richard Fairhurst wrote:

> Can anybody point me in the direction of an algorithm that will
> determine whether a closed way (polyline) is clockwise or anti-
> clockwise?
> cheers
> Richard
> _______________________________________________
> dev mailing list
> dev at openstreetmap.org
> http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/dev



More information about the dev mailing list