In what follows are various notes and equations dealing with lines, rays, and segments.
\(\begin{align} t_a &= \dfrac{(x_4 - x_3)(y_1 - y_3) - (y_4 - y_3)(x_1 - x_3)}{(y_4 - y_3)(x_2 - x_1) - (x_4 - x_3)(y_2 - y_1)}\\ t_b &= \dfrac{(x_2 - x_1)(y_1 - y_3) - (y_2 - y_1)(x_1 - x_3)}{(y_4 - y_3)(x_2 - x_1) - (x_4 - x_3)(y_2 - y_1)} \end{align}\)
\(\begin{align} P_a &= P_1 + t_a(P_2 - P_1)\\ P_b &= P_3 + t_b(P_4 - P_3) \end{align}\)