Share Pastebin
Guest
Public paste!

Untitled

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