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...
By Anonymous on the 1st of Feb 2010 11:04:47 PM
Download |
Raw |
Embed |
Report
#returns bool for whether a single Point is contained in this Polygon
def contains(point)
c = 0
last = rings[rings.length-1]
# For each ring (side) detect whether
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
(c%2 == 1)
end
Submit a correction or amendment below.
[ previous version ] | [ difference ] | Make A New Post