removed unused line_intersect()

main
Alexandre B A Villares 2020-02-04 11:06:17 -02:00
rodzic b7e552bee5
commit ea169fedc1
1 zmienionych plików z 0 dodań i 21 usunięć

Wyświetl plik

@ -121,24 +121,3 @@ def triangle_area(t):
return (t[1][0] * (t[2][1] - t[0][1]) +
t[2][0] * (t[0][1] - t[1][1]) +
t[0][0] * (t[1][1] - t[2][1]))
def line_instersect(p1, p2, p3, p4):
"""
code adapted from Bernardo Fontes
https://github.com/berinhard/sketches/
"""
x1, y1 = p1
x2, y2 = p2
x3, y3 = p3
x4, y4 = p4
try:
uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1));
uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1));
except ZeroDivisionError:
return
if not(0 <= uA <= 1 and 0 <= uB <= 1):
return
x = line_a.p1.x + uA * (line_a.p2.x - line_a.p1.x)
y = line_a.p1.y + uA * (line_a.p2.y - line_a.p1.y)
return PVector(x, y)