peano.cxx
3.59 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//arc qui remplit le carre de cote x,y
peano(x,y,n):={
local u,v;
DispG();
if (n==0) {segment(x,y+3*v);return 0;}
u:=(y-x)/3;
v:=i*u;
peano(x,x+u,n-1);
peano(x+u+v,x+u,n-1);
peano(x+2*u,y,n-1);
peano(y+v,y+2*v,n-1);
peano(x+2*(u+v),x+u+2*v,n-1);
peano(x+(u+v),x+u+2*v,n-1);
peano(x+2*v,x+2*v+u,n-1);
peano(x+3*v+u,x+u+2*v,n-1);
peano(x+2*(u+v),y+2*v,n-1);
};
//arc x y de mesure +pi/3
arcg(x,y):={
return arc(x,y,pi/3);
};
//arc x y de de mesure -pi/3
arcd(x,y):={
return arc(x,y,-pi/3);
};
// courbe de peano avec 13 arcs
//par ex peanod(-2-2*i,2-2*i,3)
peanod(x,y,n):={
local c1,b,c,d,e1,f,g,h,i1,j,k,l,m;
DispG();
if (n==0) {arc(x,y,-pi/3);return 0;}
c1:=x+(y-x)*exp(evalf(pi)*2*i/3)/3;
b:=x+(y-x)/3*exp(evalf(pi)*i/3);
c:=x+(y-x)/3*2*exp(evalf(pi)*i/3);
d:=c+(y-x)/3;
e1:=b+2*(y-x)/3;
f:=c1+(y-x)*(15+i*sqrt(3))/18;
g:=c1+(y-x)*(6+i*sqrt(3))/9;
h:=f-(y-x)/3;
i1:=h-i*(y-x)/9*sqrt(3);
j:=i1+(y-x)/3;
k:=g-i*2*(y-x)/9*sqrt(3);
l:=x+(y-x)/3;
m:=x+2*(y-x)/3;
peanog(x,b,n-1);
peanod(b,c,n-1);
peanod(c,d,n-1);
peanod(d,e1,n-1);
peanod(e1,f,n-1);
peanog(f,g,n-1);
peanog(g,h,n-1);
peanog(h,i1,n-1);
peanod(i1,j,n-1);
peanod(j,k,n-1);
peanog(k,l,n-1);
peanog(l,m,n-1);
peanod(m,y,n-1);
};
peanog(x,y,n):={
local c1,b,c,d,e1,f,g,h,i1,j,k,l,m;
DispG();
if (n==0) {
arc(x,y,pi/3);return 0;}
c1:=x+(y-x)*exp(evalf(-2*pi)*i/3)/3;
b:=x+(y-x)/3*exp(evalf(-pi)*i/3);
c:=x+(y-x)/3*2*exp(evalf(-pi)*i/3);
d:=c+(y-x)/3;
e1:=b+2*(y-x)/3;
f:=c1+(y-x)*(15-i*sqrt(3))/18;
g:=c1+(y-x)*(6-i*sqrt(3))/9;
h:=f-(y-x)/3;
i1:=h+i*(y-x)/9*sqrt(3);
j:=i1+(y-x)/3;
k:=g+i*2*(y-x)/9*sqrt(3);
l:=x+(y-x)/3;
m:=x+2*(y-x)/3;
peanod(x,b,n-1);
peanog(b,c,n-1);
peanog(c,d,n-1);
peanog(d,e1,n-1);
peanog(e1,f,n-1);
peanod(f,g,n-1);
peanod(g,h,n-1);
peanod(h,i1,n-1);
peanog(i1,j,n-1);
peanog(j,k,n-1);
peanod(k,l,n-1);
peanod(l,m,n-1);
peanog(m,y,n-1);
};
bases(x,y):={
local a,b,c,d,e1,f,g,h,i1,k;
DispG();
h:=(y-x)/3;
a:=x+h/2+i*h/2;
b:=a+i*h;
c:=b+i*h;
d:=c+h
e1:=b+h;
f:=a+h;
g:=f+h;
k:=e1+h;
i1:=d+h;
arc(a,b,pi/2);
arc(c,b,pi/2);
arc(d,c,pi/2);
arc(e1,d,pi/2);
arc(e1,f,pi/2);
arc(f,g,pi/2);
arc(g,k,pi/2);
arc(i1,k,pi/2);
};
//un arc et le motif de base
un(x,y):={
local h,a;
DispG();
h:=(y-x)/3;
a:=x+h/2+i*h/2;
arc(a-h,a,pi/2);
bases(x,y);
};
//un autre arc et le motif de base
deux(x,y):={
local h,a;
DispG();
h:=(y-x)/3;
a:=x+h/2+i*h/2;
arc(a,a-h*i,pi/2);
bases(x,y);
};
//courbe qui remplit un carre debute par le motif bases
// ex peano0(-1,2,1) ou peano0(-1,2,3)
// utilise bases un deux peano1 peano2
peano0(x,y,n):={
local a,h;
DispG();
if (n==0) {bases(x,y);return 0;}
h:=(y-x)/3;
a:=x+h;
peano0(x,a,n-1);
peano2(a+i*h,a,n-1);
peano1(a+h,y,n-1);
peano1(y+i*h,y+2*i*h,n-1);
peano1(a+h+2*i*h,a+2*i*h,n-1);
peano2(a+i*h,a+2*i*h,n-1);
peano2(x+2*i*h,a+2*i*h,n-1);
peano2(a+3*i*h,a+2*i*h,n-1);
peano1(a+h+2*i*h,y+2*i*h,n-1);
};
//courbe qui remplit un carre debute par le motif un
// ex peano1(-1,2,1)
// utilise bases un deux peano2
peano1(x,y,n):={
local a,h;
DispG();
if (n==0) {un(x,y);return 0;}
h:=(y-x)/3;
a:=x+h;
peano1(x,a,n-1);
peano2(a+i*h,a,n-1);
peano1(a+h,y,n-1);
peano1(y+i*h,y+2*i*h,n-1);
peano1(a+h+2*i*h,a+2*i*h,n-1);
peano2(a+i*h,a+2*i*h,n-1);
peano2(x+2*i*h,a+2*i*h,n-1);
peano2(a+3*i*h,a+2*i*h,n-1);
peano1(a+h+2*i*h,y+2*i*h,n-1);
};
//courbe qui remplit un carre debute par le motif deux
// ex peano2(-1,2,1)
// utilise bases un deux peano1
peano2(x,y,n):={
local a,h;
DispG();
if (n==0) {deux(x,y);return 0;}
h:=(y-x)/3;
a:=x+h;
peano2(x,a,n-1);
peano2(a+i*h,a,n-1);
peano1(a+h,y,n-1);
peano1(y+i*h,y+2*i*h,n-1);
peano1(a+h+2*i*h,a+2*i*h,n-1);
peano2(a+i*h,a+2*i*h,n-1);
peano2(x+2*i*h,a+2*i*h,n-1);
peano2(a+3*i*h,a+2*i*h,n-1);
peano1(a+h+2*i*h,y+2*i*h,n-1);
};