summaryrefslogtreecommitdiff
path: root/Master/texmf/doc/asymptote/examples/animations/torusanimation.asy
blob: 9073ab2b56ad74ff41767020ea6a33360ffd7f21 (plain)
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
import graph3; 
import animation; 
import solids;

settings.tex="pdflatex"; 
settings.prc=false; 
settings.render=4; 
 
currentprojection=orthographic((0,5,2)); 
currentlight=(0,5,5); 
unitsize(1cm); 
 
real R=3; 
real a=1; 
int n=8; 

path3[] p=new path3[n]; 
animation A; 
 
for(int i=0; i < n; ++i) { 
  triple g(real s) { 
    return ((R-a*cos(2*pi*s))*cos(2*pi/(1+i+s)), 
            (R-a*cos(2*pi*s))*sin(2*pi/(1+i+s)), 
            -a*sin(2*pi*s)); 
  } 
  p[i]=graph(g,0,1,operator ..); 
}

revolution torus=revolution(shift(R*X)*Circle(O,a,Y,32),Z);
surface s=surface(torus);
 
for(int i=0; i < n; ++i){ 
  picture fig; 
  size3(fig,400); 
  draw(fig,s,yellow); 
  for(int j=0;j <= i; ++j)
    draw(fig,p[j],blue+linewidth(4)); 
  A.add(fig); 
}

A.movie(BBox(10,Fill(rgb(0.98,0.98,0.9))),delay=100);