Can a straight line be drawn from origin to co-ordinate X,Y? Given a co-ordinate $P(X,Y)$, can a straight line be drawn from origin to $P$, if there is wall existing with end points $A(X1,Y1)$ and $B(X2,Y2)$?
My Approach:
I first of all wrote the equations from origin to $A$ and origin to $B$. Then I kept the value of $P$ in both and calculated their product, if negative or 0 then the answer is NO otherwise YES.

The problem is equivalent to check whether the segment drawn from the origin to P crosses the segment from A to B.
The equation of the line crossing the origin and $P$ has slope $Y/X$ and intercept zero. The equation of the line crossing $A$ and $B$ has slope $\displaystyle \frac{Y_2-Y_1}{X_2-X_1}$ and intercept $\displaystyle \frac{X_2 Y_1-X_1 Y_2}{X_2-X_1}$. This allows to calculate the coordinates of their intersection point. Let us call them $X_3$ and $Y_3$. We have now to check whether this point is included in the segment from the origin to $P$ and in the segment $AB$.
Considering that each of the coordinates above can be positive or negative, the segment from the origin to $P$ cannot be drawn without crossing the wall if both these conditions are satisfied:
1)  $X_3$ falls in the interval between $0$ and $X$ (or alternatively $Y_3$ falls in the interval between $0$ and $Y$);
2)$X_3$ falls in the interval between $X_1$ and $X_2$ (or, alternatively,  $Y_3$ falls in the interval between $Y_1$ and $Y_2$).
If satisfied, the first condition implies that the crossing point between the two lines is included in the segment from the origin to $P$, whereas the second one implies that the crossing point between the two lines is also included in the segment $AB$. The segment from the origin to $P$ can be drawn without crossing the wall if at least one of the two conditions is not satisfied.
