0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 function [X,Y,Z]=get_end_position(P1,P2,P3,L2)
0017
0018 x1=P1(1);
0019 y1=P1(2);
0020 z1=P1(3);
0021 x2=P2(1);
0022 y2=P2(2);
0023 z2=P2(3);
0024 x3=P3(1);
0025 y3=P3(2);
0026 z3=P3(3);
0027
0028
0029
0030 c1=(x1^2 + y1^2 + z1^2);
0031 c2=(x2^2 + y2^2 + z2^2);
0032 c3=(x3^2 + y3^2 + z3^2);
0033
0034 d1=((z3-z2)*(y2-y1)-(z2-z1)*(y3-y2))/((y3-y2)*(x2-x1)-(x3-x2)*(y2-y1));
0035 d2=((c2-c1)*(y3-y2)-(c3-c2)*(y2-y1))/(2*((y3-y2)*(x2-x1)-(x3-x2)*(y2-y1)));
0036 d3=((z2-z1)*(x3-x2)-(z3-z2)*(x2-x1))/((y3-y2)*(x2-x1)-(x3-x2)*(y2-y1));
0037 d4=((c3-c2)*(x2-x1)-(c2-c1)*(x3-x2))/(2*((y3-y2)*(x2-x1)-(x3-x2)*(y2-y1)));
0038
0039
0040
0041 a=(d2-x1)^2 + (d4-y1)^2 + z1^2 - L2^2;
0042 b=2*(d1*(d2-x1) + d3*(d4-y1) - z1);
0043 c=d1^2+d3^2 +1;
0044
0045 root=sqrt(b^2 - 4*a*c);
0046
0047
0048
0049 Z(1)=(-b+root)/(2*c);
0050 Z(2)=(-b-root)/(2*c);
0051
0052 X(1)= d1*Z(1)+d2;
0053 X(2)= d1*Z(2)+d2;
0054
0055 Y(1)= d3*Z(1)+d4;
0056 Y(2)= d3*Z(2)+d4;
0057
0058 end