All pastes #935819 Raw Edit

Untitled

public text v1 · immutable
·published 2008-03-09 22:45 UTC
rendered paste body
function hcurve(pl,pr,level)


A = [0,-1;1,0];
B = A;
if level == 0
   pmid = (pl+pr)/2;
   pup = pmid + A*(pmid-pl);
   hold on
  plot([pl(1),pup(1)],[pl(2),pup(2)]);
  plot([pup(1),pr(1)],[pup(2),pr(2)]);

else
pmid = (pl+pr)/2;
pup=pmid+A*(pmid-pl);
a=(pup+pl)/2;
b=a+A*(a-pl);
c=pup+A*(a-pl);
d=(pup+pr)/2;
e=d+A*(d-pup);
f=pup+A*(d-pup);

if b ==e
   b=a+B*(a-pl);
   c=pup+B*(a-pl);
   e=d+B*(a-pup);
   f=pup+B*(d-pup);
else
   b=b;
   c=c;
   e=e;
   f=f;
end
hcurve(b,pl,level-1);
hcurve(b,pup,level-1);
hcurve(pup,e,level-1);
hcurve(pr,e,level-1);
end