Parametric Line intersections

1. Mar 20, 2009

Pazil

Hello!

I'm having a pretty big problem intersecting parametric lines. I'm using the equations:
x = x1 + t(x2 - x1)
y = y1 + t(y2 - y1)

Given the 2 lines:
x = x1 + t(x2 - x1)
y = y1 + t(y2 - y1)

x = x3 + t(x4 - x3)
y = y3 + t(y4 - y3)

I calculate the intersection, using this:
t = ( x3 - x1 ) / ( (x2 - x1) - (x4 - x3) )

And then I would plug it into the first line...

For some odd reason...it doesn't work! And the funny thing is, that it used to work in my program. I'm not sure if I made any changes, but it's really screwing things up...

P.

2. Mar 21, 2009

HallsofIvy

Why would you think that would work? There is no reason to thing that the same value of the parameter in each line gives the point of intersection. Think of "t" as representing the time some object is at each point on the line. The same t giving the point of interesection would be equivalent to the two objects being at that point at the same time which is not necessary for a point of intersection. To make it clear that the parameters in the two different lines are not necessarily the same, use different letters, say t and s:
x = x1 + t(x2 - x1)
y = y1 + t(y2 - y1)
and
x = x3 + s(x4 - x3)
y = y3 + s(y4 - y3)

set x and y equal:
x1+ t(x2-x1)= x3+ s(x4- x3) and y1+ t(y2-y1)= y3+ s(y4-y3)
and you have two equations to solve for the two parameters s and t.

3. Mar 21, 2009

Pazil

ARRRG!!!

I was wondering why it worked before! In my first tests I had used lines of equal length and intersecting in the middle!
I now understand. I knew that you of course couldn't plug "t" into any of the two...I thought it depended to which equation you plugged it into.
Anywho, I found a complete equation finding the "t" variable for the first line:
http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/

Thanks for your help and explaining anyhow! The more math stuff I start getting through my head, the more I'll be able to learn on my own!

P.

Last edited by a moderator: Apr 24, 2017