Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Line intersects rectangle?

Posted on 2009-04-03
6
Medium Priority
?
279 Views
Last Modified: 2012-05-06
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
0
Comment
Question by:DJ_AM_Juicebox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 1000 total points
ID: 24065536
0
 
LVL 31

Assisted Solution

by:GwynforWeb
GwynforWeb earned 1000 total points
ID: 24065595
0
 
LVL 84

Expert Comment

by:ozo
ID: 24065652
http://www.siggraph.org/education/materials/HyperGraph/scanline/clipping/cliplb.htm
says that Liang-Barsky is a 36% speed improvement over  Cohen -Sutherland for 2D lines
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 31

Expert Comment

by:GwynforWeb
ID: 24065826
...the questioner is not clipping,  just detecting incidence with the rectangular.
0
 
LVL 84

Expert Comment

by:ozo
ID: 24066020
that's what line clipping algorithms do
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 24066221
...line clipping gives the clipped line segment. That is different than just detecting if the line crosses the rectangle.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are taking giant steps in technological advances in the field of wireless telephony. At just 10 years since the advent of smartphones, it is crucial to examine the benefits and disadvantages that have been report to us.
This article provides a brief introduction to tissue engineering, the process by which organs can be grown artificially. It covers the problems with organ transplants, the tissue engineering process, and the current successes and problems of the tec…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question