Find the intersection of two lines: Difference between revisions

Content deleted Content added
No edit summary
Line 2,283: Line 2,283:
{{libheader|Pygame}}
{{libheader|Pygame}}
Find the intersection by importing the external [https://www.pygame.org/docs/ PyGame] library.
Find the intersection by importing the external [https://www.pygame.org/docs/ PyGame] library.
<syntaxhighlight lang="python">def segment_intersection(a, b, c, d):
<syntaxhighlight lang="python">import pygame as pg

def segment_intersection(a, b, c, d):
""" returns a pygame.Vector2 or None if there is no intersection """
""" returns a pygame.Vector2 or None if there is no intersection """
ab, cd, ac = a - b, c - d, a - c
ab, cd, ac = a - b, c - d, a - c