| 1 |
% goldenellipse.mp |
| 2 |
% L. Nobre G. |
| 3 |
% 2012 |
| 4 |
|
| 5 |
beginfig(1); |
| 6 |
numeric u, phi, i, dstep, goldang; |
| 7 |
pen thepen; |
| 8 |
path ellia, ellib, ellic, ellid, ellip; |
| 9 |
path evola, evolb, evolc, evold, evolu; |
| 10 |
path squar; |
| 11 |
pair paira, pairb, pairc, paird; |
| 12 |
pair ellfa, squab, ellfc, squad; |
| 13 |
pair goldp; |
| 14 |
u = 5cm; |
| 15 |
phi = 0.5*(1+sqrt(5)); |
| 16 |
dstep = 5; |
| 17 |
goldang = angle(1,1/phi); |
| 18 |
thepen = pencircle scaled 0.05u; |
| 19 |
paira = (phi,0); |
| 20 |
pairb = (0,1); |
| 21 |
pairc = (-phi,0); |
| 22 |
paird = (0,-1); |
| 23 |
ellfa = (1,0); |
| 24 |
squab = (0,-phi); |
| 25 |
ellfc = (-1,0); |
| 26 |
squad = (0,phi); |
| 27 |
goldp = (phi*cosd(goldang),sind(goldang)); |
| 28 |
ellia = (phi*cosd(dstep),sind(dstep)) |
| 29 |
for i=2dstep step dstep until 90-dstep: |
| 30 |
..(phi*cosd(i),sind(i)) |
| 31 |
endfor; |
| 32 |
ellib = reverse ellia xscaled -1; |
| 33 |
ellic = ellia scaled -1; |
| 34 |
ellid = reverse ellia yscaled -1; |
| 35 |
ellip = paira--ellia--pairb--ellib--pairc--ellic--paird--ellid--cycle; |
| 36 |
evola = (cosd(dstep)**3,-phi*(sind(dstep)**3)) |
| 37 |
for i=2dstep step dstep until 90-dstep: |
| 38 |
..(cosd(i)**3,-phi*(sind(i)**3)) |
| 39 |
endfor; |
| 40 |
evolb = reverse evola xscaled -1; |
| 41 |
evolc = evola scaled -1; |
| 42 |
evold = reverse evola yscaled -1; |
| 43 |
evolu = ellfa--evola--squab--evolb--ellfc--evolc--squad--evold--cycle; |
| 44 |
squar = paira--squab--pairc--squad--cycle; |
| 45 |
z1 = goldp+whatever*(1,-1); |
| 46 |
y1 = 0; |
| 47 |
fill (x1,0)--(0,x1)--(-x1,0)--(0,-x1)--cycle withcolor blue; |
| 48 |
fill squar withcolor red; |
| 49 |
fill ellip; |
| 50 |
fill ellfa--pairb--ellfc--paird--cycle withcolor red; |
| 51 |
draw evolu withcolor blue; |
| 52 |
picture tmp; |
| 53 |
tmp = currentpicture; |
| 54 |
currentpicture := nullpicture; |
| 55 |
draw tmp rotated 45 scaled u shifted (10.5cm,14cm) withpen thepen; |
| 56 |
endfig; |
| 57 |
end. |