How can I check if a point is below a line or not ?
I\'ve the following data:
Line [ {x1,y1}, {x2,y2} ]
Points {xA,yA}, {xB,yB} ...
You could try using a cross product, but the trick is how to choose the point to form a vector, here I choose the closest point from points, assume I got pointA(you can fairly loop points to calculate to distance from loop point to Line):
v1 = {x2-x1, y2-y1} # Vector 1
v2 = {xA-x1, yA-y1} # Vector 2
cross_product = v1.x*v2.y - v1.y*v2.x
if cross_product > 0:
print 'pointA is on the counter-clockwise side of line'
elif cross_product < 0:
print 'pointA is on the clockwise side of line'
else:
print 'pointA is exactly on the line'