Subdomain Posts
Ruby | 9 hours ago
Ruby | 10 hours ago
Ruby | 17 hours ago
Ruby | 17 hours ago
Ruby | 4 days ago
Ruby | 6 days ago
Ruby | 7 days ago
Ruby | 7 days ago
Ruby | 7 days ago
Ruby | 8 days ago
Recent Posts
None | 0 sec ago
None | 25 sec ago
C++ | 1 min ago
None | 1 min ago
C | 1 min ago
None | 1 min ago
None | 1 min ago
Diff | 1 min ago
None | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 1st of Feb 2010 11:04:47 PM Download | Raw | Embed | Report
  1.       #returns bool for whether a single Point is contained in this Polygon
  2.       def contains(point)
  3.         c = 0
  4.         last = rings[rings.length-1]
  5.  
  6.         # For each ring (side) detect whether
  7.         rings.each do |ring|
  8.           if (ring.y>point.y) != (last.y>point.y)
  9.             c++ if point.x < (last.x-ring.x) * (point.y-ring.y) / (last.y/ring.y) + ring.x
  10.           end
  11.           last = ring
  12.         end
  13.  
  14.         (c%2 == 1)
  15.       end
Submit a correction or amendment below. [ previous version ] | [ difference ] | Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: