def intersects(line1, line2):
#todo: implement line-line intersection test that you read about
#iterate through all combinations of lines,
#testing whether the two intersect
for i, line1 in enumerate(myLines):
for j, line2 in enumerate(myLines):
#we don't care if a line intersects with itself
if i == j:
continue
if intersects(line1, line2):
print "Line #{} intersects with Line #{}".format(i,j)
假设你不能理解你的底线,但是我不能理解你的代码。在
您应该修改您的
lines
方法,以便它返回它绘制的直线的端点。在然后,在绘制直线时,请跟踪这些点:
^{pr2}$稍后,您可以使用前面看到的线-线相交测试来检测哪些重叠。在
相关问题 更多 >
编程相关推荐