0
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

Rewrite the line segments as line equations!

you then have:

\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}

Solving this system of equations gives the cordinate of intersection

$\endgroup$
0
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.