# Computing which side of a line a point is

I asked this question on stackoverflow:

sorry, I could not upload images, so I had to ask this way, if its not allowed, say so, I will delete it.

$AB$ is the line, $C$ is the point.

In the accepted answer of the above question, if the difference in equation is $0$, then points are collinear, so in the above image, it proves it correct as theta is same, so far so good.

Then in the image below, $C$ lies on right of line :

the fi angle is less than theta so the difference is positive. So in my program if I take $> 0$ as condition for the point on right, then the difference should always be greater than $0$ if point is on right.

But my next figure shows that the even if the point is on right of the line, the difference can be negative :

In figure 3, even though the point is on right of the line, fi is greater than theta, so the diffrence is negative.

In accepted answer, if I take positive difference for point on right side, then the above case will give wrong results.

Where am I going wrong ?

-
Rather complicated, that. Do you know the formula for computing a directed point-line distance? Alternatively, if your line segment is represented by its two endpoints, you could use the determinantal formula for the signed area of a triangle. –  Ｊ. Ｍ. Apr 3 '13 at 7:04
In the figure 2, your assumption of the angle $\phi$ is wrong. You should always take the angle the line makes with the x-axis in the anti-clockwise direction. Hence $\phi$ in that case would be 'obtuse angle' and hence the difference would turn out to be negative. –  lsp Apr 3 '13 at 7:17