MATLAB Answers

Calculate shortest distance between 2 lines.

조회 수: 62(최근 30일)
Ema
Ema 5 Dec 2016
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
Tamir Suliman 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;

로그인 to comment.

답변(2개)

Tamir Suliman
Tamir Suliman 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

로그인 to comment.


이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by