Your maths is slightly flawed, I'm afraid. The original line will indeed make a certain angle to the x-axis, but in order to know whether an additional point is on one side of it or the other, you don't just need to know the angle from the origin; you also need to know where the line cuts the x-axis, and measure the angle from there.
A better way to do it is to work out the equation of the line. Suppose your first two points are (1,3) and (3,7). You then call these (x1, y1) and (x2, y2) (sorry, can't do subscripts), and plug into the equation
(x - x1)/y - y1) = (x2 - x1)/y2 - y1)
Work all that out, and you get y = 2x + 1, which you can easily check by making sure your two initial points satisfy this equation. Now take the co-ordinates of your third point and plug them into the line equation. If y > 2x + 1, the point is above the line; if y < 2x + 1, it is below the line; and of course if they're equal, it's on the line.
Since we are (most likely) dealing with the real world, where these two things are highly unlikely, why not stop confusing the poor man with mathematical pendantry :-p
Comments 4
A better way to do it is to work out the equation of the line. Suppose your first two points are (1,3) and (3,7). You then call these (x1, y1) and (x2, y2) (sorry, can't do subscripts), and plug into the equation
(x - x1)/y - y1) = (x2 - x1)/y2 - y1)
Work all that out, and you get y = 2x + 1, which you can easily check by making sure your two initial points satisfy this equation. Now take the co-ordinates of your third point and plug them into the line equation. If y > 2x + 1, the point is above the line; if y < 2x + 1, it is below the line; and of course if they're equal, it's on the line.
Foolproof, and no trig required. :-)
Reply
Reply
Reply
Reply
Leave a comment