Find the intersection of two lines: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 2,285:
<syntaxhighlight lang="python">def segment_intersection(a, b, c, d):
""" returns a pygame.Vector2 or None if there is no intersection """
if not (denom:= ab.x * cd.y - ab.y * cd.x):
return
t = (
u = -(
if 0 <= t <= 1 and 0 <= u <= 1:
return a.lerp(b, t)
|