# Given coordinates of two lines which intersect when one line is extended, how to find their intersection coordinates?

I have two lines, each having starting and end coordinates $$(x_1,y_1),(x_2,y_2)$$ and $$(u_1,v_1),(u_2,v_2)$$, with

$$(u_1,v_1) = (0,0)$$

They are not necessarily intersecting yet, but definitely intersect when one line is extended.

Here is a sample scene

I would like to know how to find their intersection point $$(s,t)$$ only given their current coordinates.

$$\begin{cases} y = \frac{y_2-y_1}{x_2-x_1}(x_1+x) \\ v = \frac{v_2-v_1}{u_2-u_1}(u_1+u) \end{cases}$$
Working in homogeneous coordinates, let $$p_1=(x_1,y_1,1)$$, $$p_2=(x_2,y_2,1)$$, $$q_1=(u_1,v_1,1)$$ and $$q_2=(u_2,v_2,1)$$. Then computing the intersection point of the segments’ extensions is a matter of a few cross products: $$(p_1\times p_2)\times(q_1\times q_2)$$. Dehomogenize by dividing through by the last coordinate. If it’s equal to $$0$$, then the lines are parallel.