summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/lapdf/superell.tex
blob: 304cb02ebaf15c9d2c8adafa92b7df1316758214 (plain)
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
% ---------------------------------------------------------------------------
% The superellipse curve is defined by the equations:
% x(t) = a*sig(cos(t))*|cos(t)|^n    y(t) = b*sig(sin(t))*|sin(t)|^n.
% ---------------------------------------------------------------------------
\input preamble.tex

\newcount\s
\newcount\n
\Defdim(\a,9)
\Defdim(\b,9)
\newdimen\x
\newdimen\y

% ---------------------------------------------------------------------------
% We express the exponent n as a fraction N/D. If we simply used \Pow(x,n)
% instead of the two functions \Root(x,D) and then \Pot(x,N), we would get
% a numerical overflow of a dimension register.
% ---------------------------------------------------------------------------
\gdef\Superell(#1,#2){
 \def\Tx(##1,##2){
  \Dset(\x,##1) \Cos(\Np\x,\x) \Dsig(\x,\s) \Dabs(\x)
  \Root(\Np\x,#2,\x) \Pot(\Np\x,#1,##2) \Dmul(##2,\a) \Mul(##2,\s)}
 \def\Ty(##1,##2){
  \Dset(\y,##1) \Sin(\Np\y,\y) \Dsig(\y,\s) \Dabs(\y)
  \Root(\Np\y,#2,\y) \Pot(\Np\y,#1,##2) \Dmul(##2,\b) \Mul(##2,\s)}
 \Stepcol(0,23,3) \Tplot(200)(-3.1416,3.1416) \Stroke}

% ---------------------------------------------------------------------------
\begin{document}
\begin{center}
{\Huge \bf{The Superellipse}}
\bigskip

\begin{lapdf}(18,18)(-9,-9)
 \Lingrid(10)(1,0)(-9,9)(-9,9)
 \Set(\n,16)
 \Whilenum{\n>1}{\Superell(\n,2)
  \ifnum\n>6 \Sub(\n,2) \else \Sub(\n,1) \fi}
 \Superell(2,3)
 \Set(\n,5)
 \Whilenum{\n<10}{\Superell(2,\n)
  \ifnum\n<6 \Add(\n,1) \else \Add(\n,2) \fi}
 \Superell(0,1)
\end{lapdf}

$x(t)=a \cdot sig(\cos(t)) \cdot |\cos(t)|^n$ \qquad
$x(t)=b \cdot sig(\sin(t)) \cdot |\sin(t)|^n$
\end{center}
\end{document}