summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/lapdf/cycloid.tex
blob: e868d76bededa2078da111704ef110df68bf6e81 (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
50
51
52
53
54
55
56
57
58
59
60
61
\input preamble.tex

\Defnum(\n,2)
\newdimen\x
\newdimen\y
\def\ds{\displaystyle}

% -------------------------------------------------------------------------
% 1. Epicycloid:
%    x(t)=r/(n+1)*[n*cos(t)-cos(n*t)]
%    y(t)=r/(n+1)*[n*sin(t)-sin(n*t)]
% -------------------------------------------------------------------------
\def\Epicycloid(#1,#2){\Dset(\y,#2) \Dset(\x,#1) \Dadd(\x,1) \Ddiv(\y,\x)
 \def\Tx(##1,##2){\Cos(##1,##2) ##2=#1##2 \Dset(\x,##1) \x=#1\x
  \Cos(\Np\x,\x) \Sub(##2,\x) \Dmul(##2,\y)}
 \def\Ty(##1,##2){\Sin(##1,##2) ##2=#1##2 \Dset(\x,##1) \x=#1\x
  \Sin(\Np\x,\x) \Sub(##2,\x) \Dmul(##2,\y)}
 \Tplot(200)(0,6.2832)}

% -------------------------------------------------------------------------
% 2. Hypocycloid:
%    x(t)=r/(n+1)*[n*cos(t)+cos(n*t)]
%    y(t)=r/(n+1)*[n*sin(t)-sin(n*t)]
% -------------------------------------------------------------------------
\def\Hypocycloid(#1,#2){\Dset(\y,#2) \Dset(\x,#1) \Dadd(\x,1) \Ddiv(\y,\x)
 \def\Tx(##1,##2){\Cos(##1,##2) ##2=#1##2 \Dset(\x,##1) \x=#1\x
  \Cos(\Np\x,\x) \Add(##2,\x) \Dmul(##2,\y)}
 \def\Ty(##1,##2){\Sin(##1,##2) ##2=#1##2 \Dset(\x,##1) \x=#1\x
  \Sin(\Np\x,\x) \Sub(##2,\x) \Dmul(##2,\y)}
 \Tplot(200)(0,6.2832)}

% -------------------------------------------------------------------------
\begin{document}
\unitlength1.5cm

\begin{center}
{\Huge\bf{I. Epicycloids}}
\bigskip

\begin{lapdf}(12,12)(-6,-6)
 \Polgrid(1,2)(6)
 \Whilenum{\n<7}{\Stepcol(0,23,4) \Epicycloid(\n,6) \Stroke \Add(\n,1)}
\end{lapdf}

$x(t)=\frac{\ds r}{\ds{n+1}}[n\cos(t)-\cos(nt)]$ \qquad
$y(t)=\frac{\ds r}{\ds{n+1}}[n\sin(t)-\sin(nt)]$
\newpage

{\Huge\bf{II. Hypocycloids}}
\bigskip

\begin{lapdf}(12,12)(-6,-6)
 \Resetcol
 \Polgrid(1,2)(6)
 \Whilenum{\n<7}{\Stepcol(0,23,4) \Hypocycloid(\n,6) \Stroke \Add(\n,1)}
\end{lapdf}

$x(t)=\frac{\ds r}{\ds{n+1}}[n\cos(t)+\cos(nt)]$ \qquad
$y(t)=\frac{\ds r}{\ds{n+1}}[n\sin(t)-\sin(nt)]$
\end{center}
\end{document}