DJ_AM_Juicebox
asked on
Line intersects rectangle?
Hi,
How can I test if a line (defined by two x,y endpoints) intersects a rectangle?
I have a bunch of rectangles draw on a screen, and want to know if a user's mouse intersects any of them when they move the mouse. I only get mouse move messages every so often, so if the user moves the mouse fast enough, most of the mouse location points are missed. So I'm looking to figure out which rectangles could have been intersected between two mouse points.
Thanks
How can I test if a line (defined by two x,y endpoints) intersects a rectangle?
I have a bunch of rectangles draw on a screen, and want to know if a user's mouse intersects any of them when they move the mouse. I only get mouse move messages every so often, so if the user moves the mouse fast enough, most of the mouse location points are missed. So I'm looking to figure out which rectangles could have been intersected between two mouse points.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
...the questioner is not clipping, just detecting incidence with the rectangular.
that's what line clipping algorithms do
...line clipping gives the clipped line segment. That is different than just detecting if the line crosses the rectangle.
says that Liang-Barsky is a 36% speed improvement over Cohen -Sutherland for 2D lines