Effacer les filtres
Effacer les filtres

Finding the point of intersection of two lines in 3D space.

6 vues (au cours des 30 derniers jours)
tauseef ashraf
tauseef ashraf le 8 Nov 2017
Line 1 is made up of two points A and B and line 2 comprise of C and D. I tried doing following and came up with the value of parameters 't' and 's', but I need help to find out the value coordinates of the intersection point by plugging in 't' and 's'. Following is the code I used.
%%Code
A=[1, 4, -2];%[x1,y1,z1] of point A of Line1
B=[3 8 6];%[x2,y2,z2] of point B of Line1
BA= B-A; %distance between each x, y & z of A and B
syms t s;
equ1=A+t*BA
C=[3, 6, 7];D=[5,2,9];point C and D of Line2
DC=D-C;
equ2=C+s*DC;
eqns = [equ1(1,1) == equ2(1,1), equ1(1,2) == equ2(1,2)];
S = solve(eqns);
sol = [S.t; S.s]; %S.t and S.s are the values of parameter 't' and 's'.
Thanks a lot in advance for the help.

Réponses (1)

Roger Stafford
Roger Stafford le 8 Nov 2017
What is so difficult about substituting your parameter solutions into the expressions, ‘A+t*BA’ and ‘C+s*DC’? Note that if the two lines do not actually intersect in 3D space, which is quite possible, you will get different values of the ‘z’ component for ‘A+t*BA’ than for ‘C+s*DC’.
I would think that the right way to do that problem is to solve for the two points on the respective lines which are closest together. You will always get a solution for that. If the two lines actually intersect, these will be the same point (within round-off error accuracy.) However, you haven't asked how to do that.
  2 commentaires
tauseef ashraf
tauseef ashraf le 8 Nov 2017
Modifié(e) : tauseef ashraf le 8 Nov 2017
What is so difficult about substituting your parameter solutions into the expressions, ‘A+t*BA’ and ‘C+s*DC’?
Thats exactly I am looking at? Can yon please post how to do this. Sorry I may be too easy for you but I am blank at this point of time. Thanks
Roger Stafford
Roger Stafford le 9 Nov 2017
By my calculations you should have gotten the solutions sol = [t,s] = [.75,-.25] for the problem as you posed it. However, when substituting these into A+t*BA and C+s*DC, only the x and y components match. That’s not surprising, since the z components were not used in your equations. In other words, your lines do not intersect in three dimensional space.
As I mentioned earlier, one can find the two points on the respective lines that are closest, and these turn out to be [2.96,7.92,5.84] on line BA and [2.16,7.68,6.16] on DC. This is the closest the lines get to each other.

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by