Solved

Calculation of the intersection of two 3D lines in space.

Posted on 2012-04-12
6
3,419 Views
Last Modified: 2012-04-24
If I have two lines in 3 dimensional space defined by:

Line 1:  (x1,y1,z1) and (x2,y2,z2)
Line 2: (x3,y3,z3) and (x4,y4,z4)

Does anyone have the source code to solve this?
I am working in C#.Net
0
Comment
Question by:cupper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 27

Accepted Solution

by:
d-glitch earned 500 total points
ID: 37839817
The method of solution is described here:  http://mathforum.org/library/drmath/view/63719.html
0
 

Author Comment

by:cupper
ID: 37839967
The proposed solution is for a point-vector pair. I'm looking for the equations for two lines, each defined by two points in space.

Line 1:  (x1,y1,z1) and (x2,y2,z2)
Line 2: (x3,y3,z3) and (x4,y4,z4)
0
 
LVL 27

Expert Comment

by:d-glitch
ID: 37840046
For each of your line segments, you can convert to point-vector form by using either point, and the difference between the two points as the direction vector.

       (x ,y ,z ) =  (x1,y1,z1)  =  t*( x2-x1), (y2-y1), (z2-z1))   for the first line.    t=0  gives  (x1,y1,z1)     and    t=1  gives  (x2,y2,z2)
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:cupper
ID: 37860770
Sorry for getting back to this so late.
In the example provided, the final answer is unclear to me (i.e. the (X,Y,Z) location of the intersection point).
Is the final intersection point (X,Y,Z) = (5,6,2)?

Also as an aside, I'm not getting the cross product he is getting in his example (see below)

from article
"Using Bensegueni's method, we find

  a(V1 x V2) = a(-10,-11,-13)"


I get  a(V x V2) =  a (-10, 11, -13)   (i.e. middle term positive).
0
 
LVL 18

Expert Comment

by:Jose Parrot
ID: 37874532
In 2D, if two lines aren't parallel, it exists, for sure, an interception point.
In 3D there is another requirement: besides to be not parallel, the lines must be coplanar, say, they must be in a same plane.

The John Taylor's article Intersecting Lines in 3D: describes these conditions and gives some examples.

Jose
0
 
LVL 18

Expert Comment

by:Jose Parrot
ID: 37878141
Assuming the lines are defined by their end points (x1, y1, z1) and (x2, y2, z2) lets use the general parametric equation:

      x = x1 + (x2 - x1)*t
      y = y1 + (y2 - y1)*t
      z = z1 + (z2 - z1)*t

if lines are
Line A --> (xa1,ya1, za1,  xa2,ya2, za2) and
Line B --> (xb1,yb1, zb1,  xb2,yb2, zb2),

first define the parametric equations

Line A
x = xa1 + (xa2 - xa1) * ta
y = ya1 + (ya2 - ya1) * ta
z = za1 + (za2 - za1) * ta

Line B
x = xb1 + (xb2 - xb1) * tb
y = yb1 + (yb2 - yb1) * tb
z = zb1 + (zb2 - zb1) * tb

To check if they are parallel,  get the vectors for each line.

Line A
(the components of the vector are the coefficients of ta):
M1 = (xa2 - xa1) * i + (ya2 - ya1) * j + (za2 - za1) * k

Line B
(do the same as for Line A, by using the coefficients of tb):
M2 = (xb2 - xb1) * i + ...

If M1 and M2 are equal or proportional, the lines are parallel, so there is no interception point.
If not, go ahead.

Now set the x and y values.
Of course, x and y must be the same in both lines equations, so,

x = xa1 + (xa2 - xa1) * ta = xb1 + (xb2 - xb1) * tb
and
y = ya1 + (ya2 - ya1) * ta = yb1 + (yb2 - yb1) * tb

By solving tha above equations, we have values for ta and tb.
Now, just apply these values in the z equations to chek is they are true.
If so, you found the interception point, if not, they don't intercept each another.

Jose
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Nadia
Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…
Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question