Polygon geometry - any suggestions?
R. Hillen
mail at richard-hillen.de
Fri May 16 13:48:12 EDT 2008
Hello David,
I use the following function (sorry, but I forgot, who created it)
function ptInPoly p, pts
put false into inside
put item 1 of p into xt
put item 2 of p into yt
put item 1 of line 1 of pts into xOld
put item 2 of line 1 of pts into yOld
repeat with i = 2 to the number of lines in pts
put item 1 of line i of pts into xNew
put item 2 of line i of pts into yNew
if (xNew > xOld) then --flip
put xOld into x1
put xNew into x2
put yOld into y1
put yNew into y2
else
put xNew into x1
put xOld into x2
put yNew into y1
put yOld into y2
end if
if (xNew < xt) = (xt <= xOld) and ((yt-y1)*(x2-x1)) < ((y2-
y1)*(xt-x1)) then put not inside into inside
put xNew into xOld
put yNew into yOld
end repeat
return inside
end ptInPoly
> From: "David Bovill" <david at openpartnership.net>
> Subject: Polygon geometry - any suggestions?
> ..
> I am working with maps and geo-tagging media files - as part of this
> I need
> to work out if a point is within an area - simplest case a polygon,
> but this
> could be a simple volume - that is a polygon extruded to the ground.
>
Richard
More information about the use-livecode
mailing list