I wrote a little program to find the position of a point(x,y) in relation to a line defined by a point(px,py) and an angle(deg) to the x-axis (in a cartesian coordinate system).
toRadian deg = deg * (pi / 180)
lineSlope deg = tan $ toRadian deg
lineYintercept (x,y) deg = y - (x * lineSlope deg)
relativePointPosition (px,py) deg (x,y)
| s < 0 && deg>=0 && deg<90 = "Left"
| s < 0 && deg>=90 && deg<180 = "Left"
| s < 0 && deg>=180 && deg<270 = "Right"
| s < 0 && deg>=270 && deg<360 = "Right"
| s > 0 && deg>=0 && deg<90 = "Right"
| s > 0 && deg>=90 && deg<180 = "Right"
| s > 0 && deg>=180 && deg<270 = "Left"
| s > 0 && deg>=270 && deg<360 = "Left"
| s > 0 && deg==360 = "Right"
| s < 0 && deg==360 = "Left"
| otherwise = "On the line"
where s = lineSlope deg * x + lineYintercept (px,py) deg - y
It works exceptionaly well for points that are away from the line, but not so well for points that are close or on the line. How can I improve the accuracy??