Two lines and intersect when . We can solve for and in terms of the coefficients as follows. First, solve for :
(1)
Second, plug the solution into the second line equation:
(2)
Repeat this process, solving for first, to obtain an expression for :
(3)
Plug the solution into the second line equation:
(4)
Note that the denominators of both coordinates are the same modulo sign, so we can multiply either by to normalize the denominator and make its calculation reusable (below we apply this to ). This leaves us with the final expression:
(5)
The following demo allows you to specify two lines via two points each and observe the intermediate intersection point calculations.
- intX numerator:
- intX denominator:
- intY numerator:
- intY denominator:
Pingback: Finding the largest area axis-parallel square with a known center in a polygon | Clinton Freeman