Debian Codegraph @

texmf-dist/doc/latex/lapdf/superell.tex

raw
1 % ---------------------------------------------------------------------------
2 % The superellipse curve is defined by the equations:
3 % x(t) = a*sig(cos(t))*|cos(t)|^n y(t) = b*sig(sin(t))*|sin(t)|^n.
4 % ---------------------------------------------------------------------------
5 \input preamble.tex
6
7 \newcount\s
8 \newcount\n
9 \Defdim(\a,9)
10 \Defdim(\b,9)
11 \newdimen\x
12 \newdimen\y
13
14 % ---------------------------------------------------------------------------
15 % We express the exponent n as a fraction N/D. If we simply used \Pow(x,n)
16 % instead of the two functions \Root(x,D) and then \Pot(x,N), we would get
17 % a numerical overflow of a dimension register.
18 % ---------------------------------------------------------------------------
19 \gdef\Superell(#1,#2){
20 \def\Tx(##1,##2){
21 \Dset(\x,##1) \Cos(\Np\x,\x) \Dsig(\x,\s) \Dabs(\x)
22 \Root(\Np\x,#2,\x) \Pot(\Np\x,#1,##2) \Dmul(##2,\a) \Mul(##2,\s)}
23 \def\Ty(##1,##2){
24 \Dset(\y,##1) \Sin(\Np\y,\y) \Dsig(\y,\s) \Dabs(\y)
25 \Root(\Np\y,#2,\y) \Pot(\Np\y,#1,##2) \Dmul(##2,\b) \Mul(##2,\s)}
26 \Stepcol(0,23,3) \Tplot(200)(-3.1416,3.1416) \Stroke}
27
28 % ---------------------------------------------------------------------------
29 \begin{document}
30 \begin{center}
31 {\Huge \bf{The Superellipse}}
32 \bigskip
33
34 \begin{lapdf}(18,18)(-9,-9)
35 \Lingrid(10)(1,0)(-9,9)(-9,9)
36 \Set(\n,16)
37 \Whilenum{\n>1}{\Superell(\n,2)
38 \ifnum\n>6 \Sub(\n,2) \else \Sub(\n,1) \fi}
39 \Superell(2,3)
40 \Set(\n,5)
41 \Whilenum{\n<10}{\Superell(2,\n)
42 \ifnum\n<6 \Add(\n,1) \else \Add(\n,2) \fi}
43 \Superell(0,1)
44 \end{lapdf}
45
46 $x(t)=a \cdot sig(\cos(t)) \cdot |\cos(t)|^n$ \qquad
47 $x(t)=b \cdot sig(\sin(t)) \cdot |\sin(t)|^n$
48 \end{center}
49 \end{document}