Namespaces
Variants
Actions

Difference between revisions of "User:EddieBates/Asymptote-testing"

From Encyclopedia of Mathematics
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
<asy>
 +
size(12cm,0);
 +
 +
import geometry;
 +
 +
triangle T=triangleAbc(90,Tan(30),1);
 +
 +
triangle[] reverse(triangle[] arr)
 +
{
 +
  triangle[] or;
 +
  int l=arr.length;
 +
  for(int i=0; i < l; ++i) {
 +
    or.push(arr[l-i-1]);
 +
  }
 +
  return or;
 +
}
 +
 +
triangle[] dissect(triangle T, int n, bool reverse=false)
 +
{
 +
  if(n <= 0) return new triangle[]{T};
 +
  triangle[] OT;
 +
 +
  point M=curpoint(T.AB,T.b()*Tan(30));
 +
  point H=projection(T.BC)*M;
 +
  triangle[] OT1, OT2, OT3;
 +
  OT.append(dissect(triangle(H,T.B,M),n-1,!reverse));
 +
  OT.append(reverse((dissect(triangle(H,T.C,M),n-1,!reverse))));
 +
  OT.append(dissect(triangle(T.A,T.C,M),n-1,!reverse));
 +
  return OT;
 +
}
 +
 +
triangle[] DT=dissect(T,5);
 +
point O=centroid(DT[0]);
 +
path g;
 +
transform Ro=rotate(30,T.B), Re=reflect(T.BC), Roj;
 +
 +
for(int i : DT.keys) {
 +
  O=incenter(DT[i]);
 +
  g=g--O;
 +
}
 +
 +
g=reverse(g);
 +
path G, g=g--Re*reverse(g) ;
 +
for (int j=0; j < 12; j += 2) G=G--Ro^(-j)*g;
 +
 +
fill(G--cycle,0.3*blue);
 +
 +
for(int i : DT.keys) {
 +
  for (int j=0; j < 12; j += 2) {
 +
    Roj=Ro^j;
 +
    draw(Roj*DT[i],miterjoin+0.8*red);
 +
    draw(Roj*(Re*DT[i]),miterjoin+0.8*red);
 +
  }
 +
}
 +
 +
draw(G--cycle,bp+miterjoin+0.9*yellow);
 +
 +
shipout(bbox(2mm, FillDraw(black, 1mm+miterjoin+deepblue)));
 +
</asy>
 +
 +
 
<asy>
 
<asy>
 
size(10cm,0);
 
size(10cm,0);
Line 8: Line 69:
 
   if (n!=0) {
 
   if (n!=0) {
 
     pair h=point(p,length(p));
 
     pair h=point(p,length(p));
     transform tb=rotate(90-b,h)*scale(h,r);
+
     transform tb=rotate(180-b,h)*scale(h,r);
     transform ta=rotate(-90+a,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);
 
     draw(p,n/3+1/(n+1)*green+n/(n+1)*brown);
 
     tree(tb*reverse(p),n-1,a,b,r);
 
     tree(tb*reverse(p),n-1,a,b,r);
Line 17: Line 78:
  
 
tree(trk,12,a=25,b=40,r=.75);
 
tree(trk,12,a=25,b=40,r=.75);
</asy>
 
 
<asy>
 
import graph3;
 
ngraph=200;
 
size(12cm,0);
 
currentprojection=orthographic(-4,-4,5);
 
 
real x(real t), y(real t), z(real t);
 
 
real R=2;
 
void xyzset(real s){
 
  x=new real(real t){return (R+s*cos(t/2))*cos(t);};
 
  y=new real(real t){return (R+s*cos(t/2))*sin(t);};
 
  z=new real(real t){return s*sin(t/2);};
 
}
 
 
 
int n=ngraph;
 
real w=1;
 
real s=-w, st=2w/n;
 
path3 p;
 
triple[][] ts;
 
for (int i=0; i <= n; ++i) {
 
  xyzset(s);
 
  p=graph(x,y,z,0,2pi);
 
 
  ts.push(new triple[] {});
 
  for (int j=0; j <= ngraph; ++j) {
 
    ts[i].push(point(p,j));
 
  }
 
  s += st;
 
}
 
 
pen[] pens={black, yellow, red, yellow, black};
 
draw(surface(ts, new bool[][]{}), lightgrey);
 
for (int i=0; i <= 4; ++i) {
 
  xyzset(-w+i*w/2);
 
  draw(graph(x,y,z,0,2pi), 2bp+pens[i]);
 
}
 
 
</asy>
 
</asy>

Latest revision as of 15:33, 22 October 2014


How to Cite This Entry:
EddieBates/Asymptote-testing. Encyclopedia of Mathematics. URL: http://encyclopediaofmath.org/index.php?title=EddieBates/Asymptote-testing&oldid=33989