+ # Check if polygons effectively overlap each other, not only
+ # boundig boxes as dome before.
+ # Since we We are working in normalized projection coordinates
+ # we kust check if polygons intersect.
+
+ def projectionsOverlap(P, Q):
+
+ for i in range(0, len(P.v)):
+
+ v1 = Vector(P.v[i-1])
+ v1[2] = 0
+ v2 = Vector(P.v[i])
+ v2[2] = 0
+
+ for j in range(0, len(Q.v)):
+ v3 = Vector(Q.v[j-1])
+ v3[2] = 0
+ v4 = Vector(Q.v[j])
+ v4[2] = 0
+
+ ret = LineIntersect(v1, v2, v3, v4)
+ # if line v1-v2 and v3-v4 intersect both return
+ # values are the same.
+ if ret and ret[0] == ret[1] and isOnSegment(v1, v2,
+ ret[0]) and isOnSegment(v3, v4, ret[1]):
+ debug("Projections OVERLAP!!\n")
+ debug("line1:"+
+ " M "+ str(v1[0])+','+str(v1[1]) + ' L ' + str(v2[0])+','+str(v2[1]) + '\n' +
+ " M "+ str(v3[0])+','+str(v3[1]) + ' L ' + str(v4[0])+','+str(v4[1]) + '\n' +
+ "\n")
+ debug("return: "+ str(ret)+"\n")
+ return True
+
+ return False
+
+ if not projectionsOverlap(P, Q):
+ debug("\nTest 5\n")
+ debug("Projections do not overlap!\n")
+ continue