1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| '0<k<1'
for i = 1:3:length(V);
AB = [V(i+1,1)-V(i,1) V(i+1,2)-V(i,2) V(i+1,3)-V(i,3)];
AC = [V(i+2,1)-V(i,1) V(i+2,2)-V(i,2) V(i+2,3)-V(i,3)];
BC = [V(i+2,1)-V(i+1,1) V(i+2,2)-V(i+1,2) V(i+2,3)-V(i+1,3)];
if dot(N,AB) == 0
if V(i,3) == d
M(i,1:2)=[V(i,1) V(i,2)];
M(i,1:2)=[V(i+1,1) V(i+1,2)];
else
end
else
k = (-d-V(i,3))/(V(i+1,3)-V(i,3));
yi = V(i,2) + k*(V(i+1,2)-V(i,2));
xi = V(i,1) + k*(V(i+1,1)-V(i,1));
M(i,1:2)=[xi yi];
end
if dot(N,AC) == 0;
if V(i,3) == d;
M(i,1:2)=[V(i,1) V(i,2)];
M(i,1:2)=[V(i+2,1) V(i+2,2)];
else
end
else
k = (-d-V(i,3))/(V(i+2,3)-V(i,3));
yi = V(i,2) + k*(V(i+2,2)-V(i,2));
xi = V(i,1) + k*(V(i+2,1)-V(i,1));
M(i,1:2)=[xi yi];
end
if dot(N,BC) == 0;
if V(i+1,3) == d;
M(i,1:2)=[V(i+1,1) V(i+1,2)];
M(i,1:2)=[V(i+2,1) V(i+2,2)];
else
end
else
k = (-d-V(i+1,3))/(V(i+2,3)-V(i+1,3));
yi = V(i+1,2) + k*(V(i+2,2)-V(i+1,2));
xi = V(i+1,1) + k*(V(i+2,1)-V(i+1,1));
M(i,1:2)=[xi yi];
end
end
M=M;
idx=M~=0;
MM=M(idx) |
Partager