Fix bug: Polygon:contains() fails for rectangles when point left of shape

This commit is contained in:
Matthias Richter 2011-02-21 17:16:13 +01:00
parent 36fb13a69a
commit 97b470b059

View File

@ -344,8 +344,9 @@ function Polygon:contains(x,y)
local v = self.vertices
local in_polygon = false
for i = 1, #v - 1 do
if cut_ray(v[i], v[i+1]) or cross_boundary(v[i], v[i+1]) then
for i = 1, #v do
local p, q = v[i], v[(i % #v) + 1]
if cut_ray(p,q) or cross_boundary(p,q) then
in_polygon = not in_polygon
end
end