How to determine if 2 rays intersect?
I'm copying my answer for the similar question - with minimal changes.

The vector equation:
$$P_1 + \alpha * (P_2 - P_1) = P_3 + \beta * (P_4 - P_3)$$
where $P_1 = (x_1, y_1)$ etc., should have a solution, satisfying following conditions:
$$\alpha \ge 0, \beta \ge 0$$
then these two rays $(P_1, P_2)$ and $(P_3, P_4)$ do intersect. However, there are many corner cases here (for example, $P_1 = P_2$ etc.). Also, you can get wrong answers because of the limited precision of your data representation in computer.