Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I asked this question on stackoverflow: enter image description here

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 :

enter image description here

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 :

enter image description here

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 ?

share|improve this question
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. –  J. M. 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

1 Answer 1

up vote 1 down vote accepted

J.M. has it -- compute the signed determinant area of the triangle ABC

  • If it's zero, the points are colinear
  • If it's +ve then C is on one side of the line (depending on which way you write down the determinant...)
  • If it's -ve then C is on the other side.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.