title: Checking if a point is inside a polygon
body: <p>I have a class describing a Point (has 2 coordinates x and y) and a class describing a Polygon which has a list of Points which correspond to corners (self.corners)
  I need to check if a Point is in a Polygon</p>
  
  <p>Here is the function that is supposed to check if the Point is in the Polygon. I am using the Ray Casting Method    </p>
  
  <pre><code>def in_me(self, point):
          result = False
          n = len(self.corners)
          p1x = int(self.corners[0].x)
          p1y = int(self.corners[0].y)
          for i in range(n+1):
              p2x = int(self.corners[i % n].x)
              p2y = int(self.corners[i % n].y)
              if point.y &gt; min(p1y,p2y):
                  if point.x &lt;= max(p1x,p2x):
                      if p1y != p2y:
                          xinters = (point.y-p1y)*(p2x-p1x)/(p2y-p1y)+p1x
                          print xinters
                      if p1x == p2x or point.x &lt;= xinters:
                          result = not result
              p1x,p1y = p2x,p2y
           return result
  </code></pre>
  
  <p>I run a test with following shape and point:</p>
  
  <pre><code>PG1 = (0,0), (0,2), (2,2), (2,0)
  point = (1,1)
  </code></pre>
  
  <p>The script happily returns False even though the point it within the line. I am unable to find the mistake</p>