summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/lapdf/superell.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/lapdf/superell.tex')
-rw-r--r--macros/latex/contrib/lapdf/superell.tex49
1 files changed, 49 insertions, 0 deletions
diff --git a/macros/latex/contrib/lapdf/superell.tex b/macros/latex/contrib/lapdf/superell.tex
new file mode 100644
index 0000000000..7ef338a910
--- /dev/null
+++ b/macros/latex/contrib/lapdf/superell.tex
@@ -0,0 +1,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}