Original Post
I''m trying to figure out some basic line-collision stuff, and most of it works pretty well, using the good old y=mx + b equation, where m is the slope and b is the point where the line intersects the y-axis.
Anyhoo, all this works out pretty well, except on parallel lines. Now, most texts I''ve found argue that parallel line segments do not intersect. In other words, if the slope of both segments is equal, then the lines are parallel and will never intersect.
True, but if the line segments are both part of the -same- infinite line, they might overlap each other. What I want to know is if, and where, that happens.
Now, figuring out if two line segments are parallel is easy, as in that case m1 is equal to m2. (or the x-values must all be the same, in which case the line segments are exactly vertical) Figuring out if they''re both part of the same infinite line is also easy: if they are parallel AND both intercepts are equal (they intersect the y-axis at the same point), they are part of the same line, and this is the -only- case where they might overlap, right?
Now, I''m stuck. I can''t figure out how to calculate if they overlap each other, and if so, where. The line segments both have a start and an end point, and I''d like to know when segment one encounters segment 2 for the first time, and where it encounters it for the last time. (Later on, I''d like to know when two objects traveling along the segments collide if they both travel at a given speed, but I figured that''s another topic.)
Surely, there must be a relatively easy way to figure this out, and searching on various subjects has yielded no results, so far... Can anyone give me a hand on this subject?