find the line equation of two points in 3D

3 次查看(过去 30 天)
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