Calculate shortest distance between 2 lines.
16 次查看(过去 30 天)
显示 更早的评论
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 个评论
Tamir Suliman
2016-12-5
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;
回答(2 个)
Tamir Suliman
2016-12-5
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numbers and Precision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!