' 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