Fractals with Asymptote – fig0020

Category: Asymptote,Examples 2D,FractalsPh. Ivaldi @ 10 h 53 min

Figure 0002
(Compiled with Asymptote version 1.87svn-r4652)
    
size(10cm,0);

transform scale(pair center, real k) {
  return shift(center)*scale(k)*shift(-center);
}

path trk=(0,0)--(0,1);

void tree(path p, int n, real a=30, real b=40, real r=.75) {
  if (n!=0) {
    pair h=point(p,length(p));
    transform tb=rotate(180-b,h)*scale(h,r);
    transform ta=rotate(-180+a,h)*scale(h,r);
    draw(p,n/3+1/(n+1)*green+n/(n+1)*brown);
    tree(tb*reverse(p),n-1,a,b,r);
    tree(ta*reverse(p),n-1,a,b,r);
  }
}

tree(trk,12,a=25,b=40,r=.75);

Mots-clefs : , , ,


Fractals with Asymptote – fig0010

Category: Asymptote,Examples 2D,FractalsPh. Ivaldi @ 9 h 53 min

Figure 0001
(Compiled with Asymptote version 1.87svn-r4652)
    
// From documentation of Asymptote
size(250);

real a=3;
real b=4;
real c=hypot(a,b);

transform ta=shift(c,c)*rotate(-aCos(a/c))*scale(a/c)*shift(-c);
transform tb=shift(0,c)*rotate(aCos(b/c))*scale(b/c);

picture Pythagorean(int n) {
  picture pic;
  fill(pic,scale(c)*unitsquare,1/(n+1)*green+n/(n+1)*brown);
  if(n == 0) return pic;
  picture branch=Pythagorean(--n);
  add(pic,ta*branch);
  add(pic,tb*branch);
  return pic;
}

add(Pythagorean(12));

Mots-clefs : , , , ,


  • Page 2 of 2
  • <
  • 1
  • 2