29 lines
718 B
Text
29 lines
718 B
Text
function []=fcn(bitmap,ax,ay,bx,by,depth)
|
|
if depth < 0 then
|
|
return
|
|
end
|
|
|
|
dx = bx - ax; dy = ay - by;
|
|
x3 = bx + dy; y3 = by + dx;
|
|
x4 = ax + dy; y4 = ay + dx;
|
|
x5 = x4 + (dx + dy)/2; y5 = y4 + (dx - dy)/2;
|
|
|
|
scf(bitmap);
|
|
plot2d([x3 x4 x5],[y3 y4 y5],-2)
|
|
plot2d([ax bx],[ay by]); plot2d([bx x3],[by y3]);
|
|
plot2d([x3 x4],[y3 y4]); plot2d([x4 ax],[y4 ay]);
|
|
|
|
fcn(bitmap,x4,y4,x5,y5,depth-1);
|
|
fcn(bitmap,x5,y5,x3,y3,depth-1);
|
|
endfunction
|
|
|
|
plot_win = scf();
|
|
final_depth = 8;
|
|
clf();
|
|
|
|
fcn(plot_win,275,500,375,500,final_depth)
|
|
|
|
scf(plot_win);
|
|
xname('Pythagoras tree: '+string(final_depth)+' levels');
|
|
set(gca(),'isoview','on');
|
|
set(gca(),'axes_visible',['off','off','off']);
|