• Advertisement
Sign in to follow this  

Line Segment Intersection

This topic is 3403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been scratching my head over this problem for 2 days now.. so I decided to post. Given the line segments (-4,3) to (2,-3) and (-2,-4) to (6,-1) do they intersect and where? (done in parametric form). I have the following:
x(a) = -4 + 6a
y(a) = 3 - 6a

x1(a) = -2 + 8a
y1(a) = -4 + 3a

#### 
x(a) = x1(a)
-2a = 2
a = -1

y(a) = y1(a)
7 = 9a
a = 7/9
My question is this: If I get a negative alpha for x(a) = x1(a) then don't these line segments not intersect? I graphed it and it looks like they do intersect.... Any thoughts?

Share this post


Link to post
Share on other sites
Advertisement
Your problem is that you use the same parameter for both line segments; they will typically have different parameters at their intersection point.

Use x(a), y(a) for the first segment and x1(b), y1(b) for the second one and repeat your calculations.

Share this post


Link to post
Share on other sites
Your equations are wrong. The segments in parametric form are:

P(t) = (-4, 3) + t*(6, 6)
Q(s) = (-2,-4) + s*(8, 3)

You want to find the values of t and s where P(t) = Q(s) so you have to solve the following system of equations in t and s:

-4 + 6t = -2 + 8s
3 - 6t = -4 + 3s

6t - 8s = 2
6t + 3s = 7

Solve this system to find s and t. If these values are in [0,1] than the segments intersect. To find the point of intersection you can than substitute the value of s or t in the formula of the correct segment.

P.S. The solution should be t = 31/33, s = 5/11 and the two segments intersect.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement