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.
(For simplicity, assume that the line through A and B does not pass through the origin or the point P.)
Any point on the line segment from A to B has the form $t\langle x_1,y_1\rangle + (1-t)\langle x_2,y_2\rangle$ where $0\le t\le 1$.
Similarly, any point on the line segment from the origin to P has the form $u\langle x,y\rangle$ where $0\le u\le1$.
Therefore the wall will block the line segment from O to P when the equation $u\langle x,y\rangle=t\langle x_1,y_1\rangle + (1-t)\langle x_2,y_2\rangle$ has a solution where $0\le u\le1$ and $0\le t\le 1$.
Then $\langle x,y\rangle=a\langle x_1,y_1\rangle + b\langle x_2,y_2\rangle$ where $a=\frac{t}{u}$ and $b=\frac{1-t}{u}$ satisfy $a\ge0$, $b\ge0$, and $a+b>1$.
Conversely, if $\langle x,y\rangle=a\langle x_1,y_1\rangle + b\langle x_2,y_2\rangle$ where $a\ge0$, $b\ge0$, and $a+b>1$, then
$u\langle x,y\rangle=t\langle x_1,y_1\rangle + (1-t)\langle x_2,y_2\rangle$ where $u=\frac{1}{a+b}$ and $t=\frac{a}{a+b}$ satisfy $0<u<1$ and $0\le t\le 1$.
Solving the equations $x=ax_1+by_1$ and $y=ay_1+by_2$ for $a$ and $b$ gives
$\displaystyle a=\frac{xy_2-yx_2}{x_1y_2-x_2y_1}$ and $\displaystyle b=\frac{yx_1-xy_1}{x_1y_2-y_1x_2}$, so $\;\;\displaystyle a+b=\frac{x(y_2-y_1)-y(x_2-x_1)}{x_1y_2-x_2y_1}.$
Therefore the wall will block the line segment from O to P when
$\displaystyle\frac{xy_2-yx_2}{x_1y_2-x_2y_1}\ge0$, $\;\;\displaystyle\frac{yx_1-xy_1}{x_1y_2-y_1x_2}\ge0$, and $\displaystyle \frac{x(y_2-y_1)-y(x_2-x_1)}{x_1y_2-x_2y_1}>1$.