Calculate shortest distance between 2 lines.

조회 수: 20 (최근 30일)
Ema
Ema 2016년 12월 5일
답변: Walter Roberson 2016년 12월 5일
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 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
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;

Walter Roberson
Walter Roberson 2016년 12월 5일

카테고리

Help CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by