original_docstring: Fast point-in-polygon crossings algorithm, MacMartin optimization.
  
      Adapted from code by Eric Haynes
      http://www.realtimerendering.com/resources/GraphicsGems//gemsiv/ptpoly_haines/ptinpoly.c
      
      Original description:
          Shoot a test ray along +X axis.  The strategy, from MacMartin, is to
          compare vertex Y values to the testing point's Y and quickly discard
          edges which are entirely to one side of the test ray.
      
docstring: Fast point-in-polygon crossings algorithm, MacMartin optimization.
  
  Original description:
  Shoot a test ray along +X axis.  The strategy, from MacMartin, is to
  compare vertex Y values to the testing point's Y and quickly discard
  edges which are entirely to one side of the test ray.
docstring_tokens: Fast point - in - polygon crossings algorithm MacMartin optimization . Original description : Shoot a test ray along + X axis . The strategy from MacMartin is to compare vertex Y values to the testing point ' s Y and quickly discard edges which are entirely to one side of the test ray .
code: def ring_contains_point(coords, p):
      """Fast point-in-polygon crossings algorithm, MacMartin optimization.
  
      Adapted from code by Eric Haynes
      http://www.realtimerendering.com/resources/GraphicsGems//gemsiv/ptpoly_haines/ptinpoly.c
      
      Original description:
          Shoot a test ray along +X axis.  The strategy, from MacMartin, is to
          compare vertex Y values to the testing point's Y and quickly discard
          edges which are entirely to one side of the test ray.
      """
      tx,ty = p
  
      # get initial test bit for above/below X axis
      vtx0 = coords[0]
      yflag0 = ( vtx0[1] >= ty )
  
      inside_flag = False
      for vtx1 in coords[1:]: 
          yflag1 = ( vtx1[1] >= ty )
          # check if endpoints straddle (are on opposite sides) of X axis
          # (i.e. the Y's differ); if so, +X ray could intersect this edge.
          if yflag0 != yflag1: 
              xflag0 = ( vtx0[0] >= tx )
              # check if endpoints are on same side of the Y axis (i.e. X's
              # are the same); if so, it's easy to test if edge hits or misses.
              if xflag0 == ( vtx1[0] >= tx ):
                  # if edge's X values both right of the point, must hit
                  if xflag0:
                      inside_flag = not inside_flag
              else:
                  # compute intersection of pgon segment with +X ray, note
                  # if >= point's X; if so, the ray hits it.
                  if ( vtx1[0] - (vtx1[1]-ty) * ( vtx0[0]-vtx1[0]) / (vtx0[1]-vtx1[1]) ) >= tx:
                      inside_flag = not inside_flag
  
          # move to next pair of vertices, retaining info as possible
          yflag0 = yflag1
          vtx0 = vtx1
  
      return inside_flag
code_tokens: def ring_contains_point ( coords , p ) : tx , ty = p vtx0 = coords [ 0 ] yflag0 = ( vtx0 [ 1 ] >= ty ) inside_flag = False for vtx1 in coords [ 1 : ] : yflag1 = ( vtx1 [ 1 ] >= ty ) if yflag0 != yflag1 : xflag0 = ( vtx0 [ 0 ] >= tx ) if xflag0 == ( vtx1 [ 0 ] >= tx ) : if xflag0 : inside_flag = not inside_flag else : if ( vtx1 [ 0 ] - ( vtx1 [ 1 ] - ty ) * ( vtx0 [ 0 ] - vtx1 [ 0 ] ) / ( vtx0 [ 1 ] - vtx1 [ 1 ] ) ) >= tx : inside_flag = not inside_flag yflag0 = yflag1 vtx0 = vtx1 return inside_flag
short_docstring: Fast point-in-polygon crossings algorithm, MacMartin optimization.
short_docstring_tokens: Fast point - in - polygon crossings algorithm MacMartin optimization .
comment: """Fast point-in-polygon crossings algorithm, MacMartin optimization.
  
      Adapted from code by Eric Haynes
      http://www.realtimerendering.com/resources/GraphicsGems//gemsiv/ptpoly_haines/ptinpoly.c
      
      Original description:
          Shoot a test ray along +X axis.  The strategy, from MacMartin, is to
          compare vertex Y values to the testing point's Y and quickly discard
          edges which are entirely to one side of the test ray.
      """$SEP$# get initial test bit for above/below X axis
  $SEP$# check if endpoints straddle (are on opposite sides) of X axis
  $SEP$# (i.e. the Y's differ); if so, +X ray could intersect this edge.
  $SEP$# check if endpoints are on same side of the Y axis (i.e. X's
  $SEP$# are the same); if so, it's easy to test if edge hits or misses.
  $SEP$# if edge's X values both right of the point, must hit
  $SEP$# compute intersection of pgon segment with +X ray, note
  $SEP$# if >= point's X; if so, the ray hits it.
  $SEP$# move to next pair of vertices, retaining info as possible
  