There is a ball starting at point $A$ going forward in the direction towards point $B$ (so it moves along the $(AB)$ line).
A wall is represented by its two ends $W_1$ and $W_2$.
I have to solve in a general way the question "Will the ball hit the wall ?". The question seemed quite simple at first but there are a lot of particular possibilities.
So either the vectors are colinear and $(x_B-x_A)*(y_{W_2}-y_{W_1}) = (y_B-y_A)*(x_{W_2}-x_{W_1})$, and if they are, they can either be on the same line or not.
So we check if $y_{W_1}-y_A =(y_B-y_A)/(x_B-x_A)*(x_{W_1}-x_A)$ and if it's true, we then have to check if $\overrightarrow{AB}$ points towards the wall.
So I tried to compare the $x$ and $y$ coordinates but it doesn't seem sufficient to conclude if point B is between $W_1$ and $W_2$. And this is just the simple case when they are parallel and it becomes more complicated then to generally check if the ball will hit (we also have to check if the intersecting point is between the ends of the wall but that's easy).
If they're not parallel, I've determined precisely the possible intersection points (with all the particular cases of the line being vertical or horizontal and then we can't use the equations to check the intersection).
How can we check if the vector really points towards the wall ? (when they're parallel and in a general way ?)
Is there a more elegant and general way to solve the problem ?