TikZ — rolling logarithmic spiral

Obviously, this could be further simplified:

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage[T1]{fontenc}
\usepackage[sc]{mathpazo}
\usepackage{fp}
\usetikzlibrary{fixedpointarithmetic,angles,quotes}
\begin{document}
\begin{tikzpicture}[x=0.75mm, y=0.75mm, font=\scriptsize, line width=.1mm]
  \def\k{7}
  \pgfmathsetmacro\m{\k*exp(0.22*1.53*pi)}
  \pgfmathsetmacro\n{\k*exp(0.22*0.03*pi)}
  \pgfmathsetmacro\p{\k*exp(0.22*0.53*pi)}
  \pgfmathsetmacro\q{\k*exp(0.22*1.03*pi)}
  \begin{scope}[rotate={deg(0.5*pi) - atan(1/0.22) - deg(0.03*pi)}]
    \draw [red, line cap=round, line width=0.2mm, domain=-5*pi:2*pi, variable=\t, samples=500] coordinate (o) plot [fixed point arithmetic] ({\t r}:{\k*exp(0.22*\t)}) coordinate (a);
    \draw [domain=-91:0, variable=\t] plot[fixed point arithmetic] (\t, {tan(deg(1.03*pi))*\t});
    \draw  ({0.53*pi r}:{\p}) coordinate (b) -- ({1.53*pi r}:{\m}) coordinate (p) node [below] {$P$} node [pos=.65, right] {$R$};
    \draw  ({1.03*pi r}:{\q}) -- ({0.03*pi r}:{\n});
    \begin{scope}
      \clip[rotate={deg(0.53*pi) + atan(1/0.22)}] (20, 0) rectangle (65, 19.75);
      \clip[rotate={deg(0.03*pi)}] (-20, 0) rectangle (-65, -20);
      \draw  ({(\q - \m)/sin(atan(0.22)}, 0) -- ({\m*cos(deg(1.53*pi))-(\m - \q)/sin(atan(0.22)}, {\m*sin(deg(1.53*pi))});
      \draw  ({(\p - \m)/sin(atan(0.22))}, 0) --
      ({\m*cos(deg(1.53*pi))+(\p - \m)/sin(atan(0.22))}, {\m*sin(deg(1.53*pi))});
      \draw  ({(\n - \m)/sin(atan(0.22))}, 0) -- ({\m*cos(deg(1.53*pi))+(\n - \m)/sin(atan(0.22))}, {\m*sin(deg(1.53*pi))});
    \end{scope}
    \node at (-52, -17) {$s(R)$};
    \fill (0, 0) circle (0.2mm);
  \end{scope}
  \draw [line width=0.2mm] (a |- p) -- ++(-120,0) coordinate (b);
  \pic [draw, font=\tiny, "$\gamma_0$"] {angle=o--p--b};
\end{tikzpicture}
\end{document}

somewhat simpler code


So, here is the code with no rotation and clipping tricks:

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage[T1]{fontenc}
\usepackage[sc]{mathpazo}
\usepackage{fp}
\usetikzlibrary{fixedpointarithmetic}

\begin{document}
\begin{tikzpicture}[x=1mm, y=1mm]

\def\k{7} 
\def\a{0.22}

\pgfmathsetmacro\tAngle{atan(1/\a)}
\pgfmathsetmacro\tAngleRad{2*pi(\tAngle/360)}

\pgfmathsetmacro\rOne{\k*exp(\a*(\tAngleRad))}
\pgfmathsetmacro\rTwo{\k*exp(\a*(\tAngleRad+0.5*pi))}
\pgfmathsetmacro\rThree{\k*exp(\a*(\tAngleRad+pi))}
\pgfmathsetmacro\rFour{\k*exp(\a*(\tAngleRad+1.5*pi))}

\pgfmathsetmacro\lOne{(\rFour-\rThree)/sin(atan(\a))}
\pgfmathsetmacro\lTwo{(\rThree-\rTwo)/sin(atan(\a))+\lOne}
\pgfmathsetmacro\lThree{(\rTwo-\rOne)/sin(atan(\a))+\lTwo}

\pgfmathsetmacro\startAngle{-4*pi}
\pgfmathsetmacro\endAngle{2*pi}  

\foreach \step in {0, 0.5*pi, 1.5*pi} {
    \draw[line width=0.05mm] (0, 0) -- 
    ({\k*exp(\a*(\tAngleRad+\step))*cos(deg(\tAngleRad+\step))}, {\k*exp(\a*(\tAngleRad+\step))*sin(deg(\tAngleRad+\step))}); 
}

\pgfmathsetmacro\an{2*pi*(360-\tAngle)/360} 

\pgfmathsetmacro\Sx{(\k*exp(\a*\an)*sin(deg(\an)))/(tan(90-\tAngle) - tan(\tAngle+deg(\an)))}
\pgfmathsetmacro\Sy{\k*exp(\a*\an)*sin(deg(\an)) + tan(\tAngle+deg(\an))}

\draw [line cap=round, line width=0.1mm, domain=\Sx:0, variable=\x] plot [fixed point arithmetic] ({\x}, {tan(90-\tAngle)*\x}); 

\draw [line cap=round, line width=0.1mm, domain=-100:14, variable=\x] plot [fixed point arithmetic]
        ({\k*exp(\a*\an)*cos(\an r) + \x}, {\k*exp(\a*\an)*sin(\an r) + tan(\tAngle+(\an r))*\x});

\draw [line cap=round, line width=0.2mm, domain=\startAngle:\endAngle, variable=\angle, samples=5000] 
    plot [fixed point arithmetic] ({\k*exp(\a*\angle)*cos(\angle r)}, {\k*exp(\a*\angle)*sin(\angle r)});

\fill[] (\Sx, \Sy) circle (0.25mm);

\pgfmathsetmacro\Px{\k*exp(\a*(\tAngleRad+1.5*pi))*cos(deg(\tAngleRad+1.5*pi))}
\pgfmathsetmacro\Py{\k*exp(\a*(\tAngleRad+1.5*pi))*sin(deg(\tAngleRad+1.5*pi))}

\draw [line cap=butt, 
        line width=0.05mm,
        domain=180:{180-\tAngle}, 
        variable=\angle, 
        samples=100] plot [fixed point arithmetic]
    ({\Px + 6*cos(\angle)}, {\Py + 6*sin(\angle)}); 

\fill[] (\Px, \Py) circle (0.25mm);

\fill[] (\Px-\lOne, \Py) circle (0.25mm);
\fill[] (\Px-\lTwo, \Py) circle (0.25mm);
\fill[] (\Px-\lThree, \Py) circle (0.25mm);

\pgfmathsetmacro\xOne{(\Py - tan(-\tAngle)*(\Px-\lOne))/(tan(90-\tAngle) - tan(-\tAngle))}
\pgfmathsetmacro\xTwo{(\Py - tan(-\tAngle)*(\Px-\lTwo))/(tan(90-\tAngle) - tan(-\tAngle))}
\pgfmathsetmacro\xThree{(\Py - tan(-\tAngle)*(\Px-\lThree))/(tan(90-\tAngle) - tan(-\tAngle))}      

\draw [line cap=round, line width=0.1mm, domain=\xOne:{\Px-\lOne}, variable=\x] plot [fixed point arithmetic] 
    ({\x}, {tan(-\tAngle)*\x + \Py - tan(-\tAngle)*(\Px-\lOne)});           
\draw [line cap=round, line width=0.1mm, domain=\xTwo:{\Px-\lTwo}, variable=\x] plot [fixed point arithmetic]
    ({\x}, {tan(-\tAngle)*\x + \Py - tan(-\tAngle)*(\Px-\lTwo)});   
\draw [line cap=round, line width=0.1mm, domain=\xThree:{\Px-\lThree}, variable=\x] plot [fixed point arithmetic] 
    ({\x}, {tan(-\tAngle)*\x + \Py - tan(-\tAngle)*(\Px-\lThree)});

\fill[] (\xOne, {tan(90-\tAngle)*\xOne}) circle (0.25mm);
\fill[] (\xTwo, {tan(90-\tAngle)*\xTwo}) circle (0.25mm);
\fill[] (\xThree, {tan(90-\tAngle)*\xThree}) circle (0.25mm);

\fill[] (0, 0) circle (0.25mm);

\node[font=\scriptsize] at ({\Px + 3.5*cos(180-0.5*\tAngle)}, {\Py + 3.5*sin(180-0.5*\tAngle)}) {$\gamma_0$};
\node[font=\scriptsize, anchor=north] at ({\Px}, {\Py}) {$P$};
\node[font=\scriptsize, anchor=north] at ({\Px}, {\Py+12}) {$R$};
\node[font=\scriptsize, anchor=north] at ({-50}, {\Py}) {$s(R)$};
\end{tikzpicture}
\end{document}

enter image description here

Tags:

Tikz Pgf