find the line equation of two points in 3D

조회 수: 3 (최근 30일)
noa
noa 2012년 10월 15일
hi.
I have a problem, here is my code
cama=[-412.3, 24.6, 630.9];
camb=[483.4, 35.8, 605.5];
dz=-36;
loca=[-0.3, 24.8, 0];
locb=[44.5, 23.9, 0];
figure; hold on; grid on;view(0,0)
plot3(cama(1), cama(2), cama(3), 'r*');
plot3(camb(1), camb(2), camb(3), 'b*');
plot3(loca(1), loca(2), loca(3), 'ro');
plot3(locb(1), locb(2), locb(3), 'bo');
plot3([cama(1), loca(1)], [cama(3), loca(3)], [cama(3), loca(3)], 'k')
plot3([camb(1), locb(1)], [camb(3), locb(3)], [camb(3), locb(3)], 'k')
i need to find the point of the intersecting lines or a close point, one that is on z=-36, how can I do that?
thanks

답변 (2개)

Babak
Babak 2012년 10월 15일
To find the intersection of two lines (curves) for which you have numerical data, like f(n) and g(n) you can first compute h(n) = abs(f(n)-g(n)) then find the minimum of h(n), find the index j at which h(n) has a local minimum and check that either (f(j)-g(j))*(f(j+1)-g(j+1))<0 or (f(j)-g(j))*(f(j-1)-g(j-1))<0.
If none of the two is correct then the local minimum you've found does not correspond to an intersection point but if (f(j)-g(j))*(f(j+1)-g(j+1))<0 the intersection is happenning from j to j+1 index and if (f(j)-g(j))*(f(j-1)-g(j-1))<0 then the intersection is happennig from j-1 to j index. either way to find the more precise location of the intersection you can interpolate between the data of f(j)-g(j) and f(j+1)-g(j+1) for example. Or obviously interpolate between the data of f(j)-g(j) and f(j+1)-g(j+1).
  댓글 수: 1
noa
noa 2012년 10월 15일
편집: noa 2012년 10월 15일
i really dont understand
I only have two points for each line
L1=cama-->loca
L2=camb-->locb

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2012년 10월 15일

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by