| 1 |
% Maxime Chupin, Alexander Grahn |
| 2 |
% 2022/01/21 |
| 3 |
|
| 4 |
prologues:=3; |
| 5 |
outputtemplate := "%j_%c.mps"; |
| 6 |
outputformat := "mps"; |
| 7 |
|
| 8 |
verbatimtex |
| 9 |
\documentclass{article} |
| 10 |
%\usepackage{lmodern} |
| 11 |
\usepackage[tt=false]{libertine} |
| 12 |
\usepackage[libertine]{newtxmath} |
| 13 |
\usepackage{amsmath} |
| 14 |
\begin{document} |
| 15 |
etex |
| 16 |
|
| 17 |
u:=4cm; |
| 18 |
|
| 19 |
vardef proj(expr P,M,N)= |
| 20 |
save H; |
| 21 |
pair H; |
| 22 |
H=whatever [M,N]; |
| 23 |
H-P=whatever * (M - N) rotated 90; |
| 24 |
H |
| 25 |
enddef; |
| 26 |
|
| 27 |
path dr,cercle,drb,scara; |
| 28 |
pair A,B,C,D,Q,T,O',P,O,M; |
| 29 |
O:=(0,0); |
| 30 |
O':=(-u/3,0); |
| 31 |
A:=(u/sqrt(2),u/sqrt(2)) shifted O'; |
| 32 |
B:=(u/sqrt(2),-u/sqrt(2)) shifted O'; |
| 33 |
C:=(-u/sqrt(2),-u/sqrt(2))shifted O'; |
| 34 |
D:=(-u/sqrt(2),u/sqrt(2)) shifted O'; |
| 35 |
dr:=A--C; |
| 36 |
drb:=B--D; |
| 37 |
|
| 38 |
%scarabaeus construction |
| 39 |
for i:=0 upto 100: |
| 40 |
if i=0: |
| 41 |
P:=A; |
| 42 |
Q:=O'; |
| 43 |
M:=proj(O,P,Q); |
| 44 |
scara:=M; |
| 45 |
else: |
| 46 |
scara:=M; |
| 47 |
for j:=1 upto 4: |
| 48 |
k:=4*(i-1)+j; |
| 49 |
if (k<200) or (k=200): |
| 50 |
P:=point (k*0.005) of dr; |
| 51 |
cercle:=halfcircle |
| 52 |
scaled 2u rotated 45 shifted P; |
| 53 |
if k=0: |
| 54 |
Q:=O'; |
| 55 |
fi; |
| 56 |
if (k<>0) and (k<>200): |
| 57 |
Q:=cercle intersectionpoint drb; |
| 58 |
fi; |
| 59 |
if k=200: |
| 60 |
Q:=O'; |
| 61 |
fi; |
| 62 |
else: |
| 63 |
P:= point (2-k*0.005) of dr; |
| 64 |
cercle:=halfcircle |
| 65 |
scaled 2u rotated (-135) shifted P; |
| 66 |
if k<400: |
| 67 |
Q:=cercle intersectionpoint drb; |
| 68 |
fi; |
| 69 |
if k=400: |
| 70 |
Q:=O'; |
| 71 |
fi; |
| 72 |
fi; |
| 73 |
M:=proj(O,P,Q); |
| 74 |
scara:=scara--M; |
| 75 |
endfor; |
| 76 |
fi; |
| 77 |
beginfig(i) %red scarabaeus segments |
| 78 |
pickup pencircle scaled 1pt; |
| 79 |
draw scara withcolor red; |
| 80 |
setbounds currentpicture to |
| 81 |
(u,1.2u)--(u,-1.2u)--(-1.5u,-1.2u)--(-1.5u,1.2u)--cycle; |
| 82 |
endfig; |
| 83 |
beginfig(i+101) %moving construction lines and labels |
| 84 |
draw 12[P,Q]--12[Q,P] dashed evenly; |
| 85 |
draw O--M dashed evenly; |
| 86 |
pickup pencircle scaled 1.4pt; |
| 87 |
draw P--Q withcolor blue; |
| 88 |
label.rt(btex $2l$ etex, 0.5[P,Q]); |
| 89 |
dotlabel.urt(btex $P$ etex, P); |
| 90 |
dotlabel.llft(btex $Q$ etex,Q); |
| 91 |
dotlabel.top(btex $M$ etex,M); |
| 92 |
setbounds currentpicture to |
| 93 |
(u,1.2u)--(u,-1.2u)--(-1.5u,-1.2u)--(-1.5u,1.2u)--cycle; |
| 94 |
endfig; |
| 95 |
if (i/2.-floor(i/2.))=0: %gray lines every second image |
| 96 |
beginfig(i/2+202) |
| 97 |
draw P--Q withcolor 0.8 white; |
| 98 |
setbounds currentpicture to |
| 99 |
(u,1.2u)--(u,-1.2u)--(-1.5u,-1.2u)--(-1.5u,1.2u)--cycle; |
| 100 |
endfig; |
| 101 |
fi; |
| 102 |
endfor; |
| 103 |
|
| 104 |
%coordinate axes and stationary stuff |
| 105 |
beginfig(253); |
| 106 |
path ida,mida; |
| 107 |
drawarrow(-1.5u,0)--(1u,0); |
| 108 |
drawarrow(0,-1.2u)--(0,1.2u); |
| 109 |
ida:=12[A,C]--12[C,A]; |
| 110 |
mida:=(12[D,B]--12[B,D]); |
| 111 |
draw ida dashed evenly; |
| 112 |
draw mida dashed evenly; |
| 113 |
label.top(btex $a$ etex, 0.5[O,O']); |
| 114 |
label.top(btex $x$ etex, (0.8u,0)); |
| 115 |
label.rt(btex $y$ etex, (0,u)); |
| 116 |
label.bot(btex\itshape{\underline{scarabaeus}} etex,(-1.1u,1.1u)); |
| 117 |
label.bot(btex $r=l\cos 2t-a\cos t$ etex, (-u/2,1.1u)); |
| 118 |
dotlabel.urt(btex $O'$ etex, O'); |
| 119 |
dotlabel.urt(btex $O$ etex, O); |
| 120 |
dotlabel.rt(btex $A$ etex,A); |
| 121 |
dotlabel.rt(btex $B$ etex,B); |
| 122 |
dotlabel.lft(btex $C$ etex,C); |
| 123 |
dotlabel.lft(btex $D$ etex,D); |
| 124 |
setbounds currentpicture to |
| 125 |
(u,1.2u)--(u,-1.2u)--(-1.5u,-1.2u)--(-1.5u,1.2u)--cycle; |
| 126 |
endfig; |
| 127 |
|
| 128 |
end. |