def clipConvex(poly0, poly1):
 res = poly0
 for p1idx in xrange(0, len(poly1)):
  src = res
  res = []
  p0 = poly1[(p1idx - 1)]
  p1 = poly1[p1idx]
  for n in xrange(0, len(src)):
   p = src[n]
   if (not _isLeft(p0, p1, p)):
    if _isLeft(p0, p1, src[(n - 1)]):
     res.append(lineLineIntersection(p0, p1, src[(n - 1)], p))
    res.append(p)
   elif (not _isLeft(p0, p1, src[(n - 1)])):
    res.append(lineLineIntersection(p0, p1, src[(n - 1)], p))
 return numpy.array(res, numpy.float32)

def clipConvex ( poly0 , poly1 ) : res = poly0 for p1idx in xrange ( 0 , len ( poly1 ) ) : src = res res = [ ] p0 = poly1 [ ( p1idx - 1 ) ] p1 = poly1 [ p1idx ] for n in xrange ( 0 , len ( src ) ) : p = src [ n ] if ( not _isLeft ( p0 , p1 , p ) ) : if _isLeft ( p0 , p1 , src [ ( n - 1 ) ] ) : res . append ( lineLineIntersection ( p0 , p1 , src [ ( n - 1 ) ] , p ) ) res . append ( p ) elif ( not _isLeft ( p0 , p1 , src [ ( n - 1 ) ] ) ) : res . append ( lineLineIntersection ( p0 , p1 , src [ ( n - 1 ) ] , p ) ) return numpy . array ( res , numpy . float32 )
cut the convex polygon 0 so that it completely fits in convex polygon 1 .