# How to solve for $s$ in this equation?

I'm trying to find the intersection of two lines, here are the equations I arrived at by equating both parametric line equations for both $x$ and $y$: \begin{align} x_1 + t(x_2 - x_1) = x_3 + s(x_4 - x_3) \quad&(1) \\ y_1 + t(y_2 - y_1) = y_3 + s(y_4 - y_3) \quad&(2) \\ \end{align} Now I wrote (2) in terms of t as follows: $$t = \frac{y_3 + s(y_4 - y_3) - y_1}{(y_2 - y_1)}$$ Which I then substituted back in (1) : $$x_1 + (\frac {y_3 + s(y_4 - y_3) - y_1}{(y_2 - y_1)})(x_2 - x_1) = x_3 + s(x_4 - x_3)$$ Move the all terms containing an $s$ to one side: $$(\frac {y_3 + s(y_4 - y_3) - y_1}{(y_2 - y_1)})(x_2 - x_1) - s(x_4 - x_3) = x_3 - x_1$$ Now I'm clueless where to go from there, I know I should find the value for $s$ and go from there to find $t$ by substitution, but not really sure how.

• Your last equation is linear in $s\,$. Just group everything in the form $a\,s+b=0\,$.
– dxiv
Feb 19, 2017 at 2:31

A good trick for this sort of thing: when you've got a whole bunch of "variables" that are being treated as constants, replace them with constants at random and see what steps you would follow then. For example, if the equation were $\frac{1 + s(3 - 2) - 4}{5 - 4})(8 - 6) - s(9 - 3) = 3 - 6$, what would you do? After simplifying the subtractions, you'd have $\frac{1 + s - 4}{1}2 - 6s = -3$. Then you'd group like this: $(\frac{1}{1} + \frac{1}{1}s - \frac{4}{1})2 - 6s = -3$, then $2 + 2s - 8 - 6s = -3$, and finally $-4s - 6 = -3$. From there, solving for $s$ would be easy.
So do the same thing with your equation. You can't do the first part - simplifying the subtractions - because you don't know the numbers. But you can do the rest. For example, I'd first rewrite it as $(\frac{y_3}{y_2 - y_1} + \frac{y_4 - y_3}{y_2 - y_1}s - \frac{y_1}{y_2 - y_1})(x_2 - x_1) - s(x_4 - x_3) = x_3 - x_1$. Then keep going - distribute, regroup, and solve.