My Math Forum Overlap of line segments

 Algebra Pre-Algebra and Basic Algebra Math Forum

 November 15th, 2009, 05:08 PM #1 Newbie   Joined: Oct 2009 Posts: 3 Thanks: 0 Overlap of line segments I have a very simple question that may have a very complex answer. Given a line on a cartesian coordinate system and two segments on that line, how do you check if, and if so, by how much, those lines overlap? The given information is the coordinates of the lines' endpoints as well as the slope of the line. I'm hoping for a solution that isn't as byzantine and heavy-handed as comparing coordinates of the points, since that could end up being very confusing and ambiguous in the system for which I'm using this.
 November 15th, 2009, 09:08 PM #2 Senior Member   Joined: Feb 2009 From: Adelaide, Australia Posts: 1,519 Thanks: 3 Re: Overlap of line segments If you are quite sure that the segments are on the exact same line, like drinking straws on a taut string, it should fairly simple. Suppose the xy-coordinates of the first segment are (a,b)-(c,d) and those of the second segment are (e,f)-(g,h) where these variables are ordered so that a
 November 15th, 2009, 09:40 PM #3 Senior Member   Joined: Feb 2009 From: Adelaide, Australia Posts: 1,519 Thanks: 3 Re: Overlap of line segments Code: p=min(a,c); q=min(e,g); if p0 then overlap_fraction = m/(max(a,c,e,g)-min(a,c,e,g)) If a=c (so the line is vertical and the slope infinite), use b,d,f,h instead of a,c,e,g.
 November 16th, 2009, 04:20 PM #4 Newbie   Joined: Oct 2009 Posts: 3 Thanks: 0 Re: Overlap of line segments And how would you calculate the resulting single segment? It can't just be (a,b) to (g,h), that doesn't account for the possibility of a segment within the other. Would it be enough to test if c is further to the left than g? I'm assuming (a,b)-(c,d) is the segment on the left in most typical cases, of course.
 November 17th, 2009, 05:23 AM #5 Senior Member   Joined: Feb 2009 From: Adelaide, Australia Posts: 1,519 Thanks: 3 Re: Overlap of line segments Suppose the overlap segment is stored as (i,j)-(k,l). I think this code should work: Code: `if m>0 then if pc then k=a; l=b else k=c; l=d; if eg then k=e; l=f else k=g; l=h; if a

 Tags line, overlap, segments

,

,

,

,

,

,

,

,

,

,

,

,

,

,

# formula to determine how much segments overlap

Click on a term to search for related topics.
 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post nilesh33 Algebra 0 February 20th, 2013 10:17 AM Jmlee19 Calculus 5 December 6th, 2012 02:23 PM master555 Applied Math 0 December 2nd, 2011 05:56 PM 1101 Algebra 4 February 22nd, 2011 11:43 AM andoxx Algebra 7 February 8th, 2011 08:09 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top