get_intersection_point_bruteforce

get_intersection_point_bruteforce#

zeroheliumkit.src.utils.get_intersection_point_bruteforce(p1: Point, p2: Point, p3: Point, p4: Point) Point[source]#

Calculates the intersection point between two line segments using a brute-force approach.

Parameters:
  • p1 (Point) – The starting point of the first line segment.

  • p2 (Point) – The ending point of the first line segment.

  • p3 (Point) – The starting point of the second line segment.

  • p4 (Point) – The ending point of the second line segment.

Returns:

The intersection point of the two line segments.

Return type:

Point

Raises:

TopologyError – If the constructed lines (p1,p2) and (p3,p4) do not intersect.

Example

>>> p1 = Point(0, 0)
>>> p2 = Point(2, 2)
>>> p3 = Point(0, 2)
>>> p4 = Point(2, 0)
>>> result = get_intersection_point_bruteforce(p1, p2, p3, p4)
>>> print(intersection_point)
    POINT (1 1)