![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
How to find whether 2 segments overlap each other or noti have 2 segments
the first line has points whose coordinates are: (x1,y1) and (x2,y2) and second line has points whose coordinates are: (u1,v1) and (u2,v2) i want to find out whether these 2 segments overlap each other or not (whether thy have more than 1 point common) for example A(2,2),B(6,6) & C(3,3),D(5,5) now segment AB & CD overlaps each other how to find it out mathematically plz give explanation |
|||
|
#2
|
|||
|
|||
Re: how to find whether 2 segments overlap each other or notQuote:
I suggest that you might start by visualization, aided by actual visual construction. In other words... Draw the lines (with pencil and paper). Try to see whether you can convince yourself that the following claims are always true. First of all, you need to know that the two infinite lines (the lines that contain the given segments) are collinear. That is, the equations for the lines are linearly dependent and consistent. In general what might happen between the line segments? I think that there are three possibilities: I suggest that you draw line segments that illustrate these three conditions. Are all possibilities covered? What else could happen with segments from collinear lines? Then, given that the lines are collinear, and (x1 != x2) and (u1 != u2), lets see if we can make some general observations that might lead to something useful. Let minx = min(x1,x2), maxx = max(x1,x2) Let minu = min(u1,u2), maxu = max(u1,u2) Consider the two cases:
If these claims are true, then an implementation can be straightforward. Of course it is possible that a more elegant solution can be formulated, but I think an implementation that is obtained directly from observation might be practical, at least for starters. Regards, Dave |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to find intersection point of 2 segments | mandar_999 | C++ Forum | 4 | 17-Mar-2009 08:51 |
| Find the @ in a file | Bradster | C++ Forum | 9 | 09-Jul-2007 13:59 |
| Program that can find a patern | Anyways | C++ Forum | 4 | 23-Mar-2005 02:11 |
| HELP!: find window width? Center a <div>? | Kingherc | Web Design Forum | 2 | 06-Jul-2003 06:25 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The