Untitled
By: a guest | Feb 1st, 2010 | Syntax:
Ruby | Size: 0.38 KB | Hits: 94 | Expires: Never
#returns bool for whether a single Point is contained in this Polygon
def self.contains(point)
c = 0
last = rings[rings.length-1]
rings.each do |ring|
if (ring.y>point.y) != (last.y>point.y)
c++ if point.x < (last.x-ring.x) * (point.y-ring.y) / (last.y/ring.y) + ring.x
end
last = ring
end