-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphIso.asy
48 lines (40 loc) · 1.06 KB
/
graphIso.asy
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
42
43
44
45
46
47
48
import animation2;
animation a;
size(1200,300,(-1.5,-1.5),(10.5,1.5));
int frames = 19;
real angle = 180;
pair shift = (3,0);
pen p = black+1.5bp;
pen q = blue+1.5bp;
path startGraph1 = (-1,-1)--(-1,1)--(1,1)--(1,-1);
path endGraph1 = (2,1)--(2,-1)--(4,-1)--(4,1);
path startGraph2 = shift((6,0))*startGraph1;
path endGraph2 = (8,1)--(10,1)--(8,-1)--(10,-1);
transform spinShift(int n) {
return shift(n/frames*shift)*rotate(n/frames*angle);
}
path zigZag(int n) {
path zig;
for(int i = 0;i<size(startGraph2);++i) {
real t = n/frames;
pair next = (1-t)*point(startGraph2,i)+t*point(endGraph2,i);
zig = zig--next;
}
return zig;
}
void doDrawing(path startGraph, pen q, path endGraph, pen p, int i){
draw(endGraph,p);
draw(startGraph,q);
for(int j = 0; j < 4;++j){
dot(point(endGraph,j));
dot(point(startGraph,j),blue);
}
}
for(int i = 0; i < frames+1;++i){
transform t = spinShift(i);
doDrawing(t*startGraph1,q,endGraph1,p,i);
path temp = zigZag(i);
doDrawing(temp,q,endGraph2,p,i);
a.add(); erase();
}
a.movie(firstDelay=400,lastDelay=400);