Calculate shortest distance between 2 lines.
25 views (last 30 days)
Show older comments
I got 2 lines:
Line 1 = (x,y,z) ∈ (Real numbers/3d), x=10+3t, y=−1+2t, z=−1.5−0.01t, t ∈ Real numbers
Line 2 = (x,y,z) ∈ (Real numbers/3d), x=−1−0.1t, y=2t, z=−2.5+0.02t, t ∈ Real numbers
unit of lenght (meters)
First i don't seem to be able to plot it since i have not stated the t free variable.
Since i get this error
Error using plot3
Data must be numeric, datetime, duration or an array convertible to double.
Error in Euklidisk_geometri_1 (line 5)
x = 10+3*t ; y = -1+2*t ; z = -1.5+0.01*t; plot3(x,y,z)
Second i wonder if my calulculations are correct in matlab: I get D(distance) to be 1.0001 meters.
clf
syms t
x = 10+3*t ; y = -1+2*t ; z = -1.5+0.01*t; plot3(x,y,z)
hold on
x = -1-0.1*t ; y = 2*t ; z = -2.5 +0.02*t; plot3(x,y,z)
L1 = (([10,-1,-1.5])+t*([3,2,-0.01]))
L2 = (([-1,2,-2.5])+t*([-0.1,2,0.02]))
v1 = [3,2,-0.01]
v2 = [-0.1,2,0.02]
N = (cross(v1,v2))
P1 = [10,-1,-1.5]
P2 = [-1,2,-2.5]
P = P2-P1
C = P.*N
d = (P.*N/N.^2).*N
D = norm(sqrt(d.^2))
1 Comment
Tamir Suliman
on 5 Dec 2016
Data must be numeric, datetime, duration or an array convertible to double.
instead of syms t you should have some thing like
t=-10:0.001:10;
Answers (2)
Tamir Suliman
on 5 Dec 2016
Data must be numeric, datetime, duration or an array convertible to double.
instead of syms t you should have some thing like
t=-10:0.001:10;
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!