How do you determine whether the polygon is clockwise or
counter-clockwise.
Thank you,
Michael Simpson
t_ms...@qualcomm.com
I think this refers to the direction in which the verticies have been
digitized/generated etc. There's a "from node" and a "to node" with a
series of verticies delineating any arc/polygon giving it a clockwise
or counter clockwise direction.
Ian Gillespie
WID-Geomatics Unit
Environment Canada
(opinions expressed are mine)
Assuming you're working in ArcView, the Polygon.Make request automatically
orients the rings correctly, whatever the input point list is. Nonetheless,
if you're interested in testing a particular ring the following Avenue
script should do the trick:
' Ring.IsClockwise
' Determines if ring is clockwise
' Adapted from p. 26 of Computational Geometry in C by Joseph O'Rourke
' Arguments: plist = list of points representing ring
' Returns: Boolean (or nil if polygon is degenerate)
plist = SELF.Get(0)
sum = 0
p0 = plist.Get(0)
a0 = p0.GetX
a1 = p0.GetY
i = 1
n = plist.Count - 1
while (i < n)
p1 = plist.Get(i)
p2 = plist.Get(i+1)
b0 = p1.GetX
b1 = p1.GetY
c0 = p2.GetX
c1 = p2.GetY
sum = sum + (a0 * b1) - (a1 * b0) + (a1 * c0) - (a0 * c1) + (b0 * c1) -
(c0 * b1)
i = i + 1
end
if (sum = 0) then
return nil
else
return (sum < 0)
end
The following script gives an example of executing the test:
out_name = FileName.GetCWD.MakeTmp("Report","txt")
out_name = FileDialog.Put(out_name, "*.txt", "Output Report")
if (out_name = nil) then return nil end
lf = LineFile.Make(out_name, #FILE_PERM_WRITE)
theFTab = av.GetActiveDoc.GetActiveThemes.Get(0).GetFTab
theShapeField = theFTab.FindField("Shape")
for each r in theFTab
thePoly = theFTab.ReturnValue(theShapeField,r)
i = 0
for each ring in thePoly.AsPolyLine.AsList
IsCW = av.Run("Ring.IsClockwise",{ring}).AsString
recno = r.AsString
ringno = i.AsString
numv = ring.Count.AsString
outrec = "Polygon"++recno++"Ring"++ringno++"Vertices"++numv+":
clockwise ="++IsCW
lf.WriteElt(outrec)
i = i + 1
end
end
lf.close
--Mark