# Help me please! 3D Line Segments

• Dec 18th 2007, 06:35 PM
jacksoncapper
Help me please! 3D Line Segments
I would really appreciate it if anyone can help me here with this simple problem that I think requires a complex solution but not sure.

I have two 3D line segments, each line segment represented by two 3D (x,y,z) points. I need to know if and where these two line segments intersect.

Thankyou!
• Dec 18th 2007, 09:18 PM
Here is one method:

If the points of a line segment are P_1 and P_2 then the line segment can be described as P_1+t(P_2-P_1). Assuming P_1 and P_2 are the endpoints of the segment, t is between 0 and 1.
This means that any point on the segment can be written (x(t),y(t),z(t)).
Using the same system we can write the second line segment as (x'(s),y'(s),z'(s)).
The lines intersect if and only if there exists a value for s and t such that these points are the same. This point will be the point of intersection.
Solving the system of equations:
x(t) = x'(s)
y(t) = y'(s)
z(t) = z'(s)
will yield the point of intersection. If there are no solutions, the lines do not intersect.
• Dec 18th 2007, 09:40 PM
jacksoncapper
Aw wow! I like that solution, I just have to get my head around it lol. Thankyou so much.

So from what I understand is we are splitting the problem into 3 problems; One for each dimension (x, y, and z). For each problem, we substitute P_1 and P_2 with the dimensional value (x, y, or z) of the respective point (1, or 2) of the line segment equation. We simultaneously solve for t, and s. If there is a solution for each dimension then we have the point of intersection otherwise there is no intersection. Or have I got this all wrong...

:confused:

Thankyou again!
• Dec 19th 2007, 03:45 PM