MCPcopy Create free account
hub / github.com/google-deepmind/alphageometry / line_segment_intersection

Function line_segment_intersection

numericals.py:569–574  ·  view source on GitHub ↗
(l: Line, A: Point, B: Point)

Source from the content-addressed store, hash-verified

567
568
569def line_segment_intersection(l: Line, A: Point, B: Point) -> Point: # pylint: disable=invalid-name
570 a, b, c = l.coefficients
571 x1, y1, x2, y2 = A.x, A.y, B.x, B.y
572 dx, dy = x2 - x1, y2 - y1
573 alpha = (-c - a * x1 - b * y1) / (a * dx + b * dy)
574 return Point(x1 + alpha * dx, y1 + alpha * dy)
575
576
577def line_line_intersection(l1: Line, l2: Line) -> Point:

Callers

nothing calls this directly

Calls 1

PointClass · 0.70

Tested by

no test coverage detected