<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% ---------------------------------------------------------------------------
% 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&gt;1}{\Superell(\n,2)
  \ifnum\n&gt;6 \Sub(\n,2) \else \Sub(\n,1) \fi}
 \Superell(2,3)
 \Set(\n,5)
 \Whilenum{\n&lt;10}{\Superell(2,\n)
  \ifnum\n&lt;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}
</pre></body></html>