Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line intersection

How to find whether a line intercepted in a polygon


1 Answers

The question is a little bit ambiguous but let's try anyway:

Assume the points (x,y) on the line are defined by the equation Ax + By + C = 0. Then we can obviously determine if a point (x,y) is on the line by evaluating Ax + By + C. If the point is not on the line then the sign of Ax + By + C tells us on which side of the line the point is. Hence by inspecting the signs of the expression Ax + By + C for each vertex (x,y) of the polygon, we can determine if all points of the polygon are on the same side of line or not.

(A slightly different problem would be to determine if a polygon intersects a line segment.)

like image 170
Accipitridae Avatar answered Mar 10 '26 04:03

Accipitridae