2

I have been trying to create a picture of a Fermat's (or parabolic) spiral, with a couple of labels on it.

I have tried to use some of the responses in TikZ — involute of a circle, as well as the rooty helix, bBut can't seem to get it working.

Basically what I am after, are two intersecting fermat spirals each with a different background colour:

enter image description here

I also want labels that signify the components of growth as it expands. If the colour can get darker as it grows, as the rooty helix does, that would be an added bonus.

8

My answer to spiral spring in tikz provides a way to that with a command:

\newcommand\spiral{} % just for safety
\def\spiral[#1](#2)(#3:#4)(#5:#6)[#7]{%
%\spiral[options](center)(start angle:end angle)(start radius:final radius)[revolutions]
\pgfmathsetmacro{\domain}{#4+#7*360}
\pgfmathsetmacro{\growth}{180*(#6-#5)/(pi*(\domain-#3))}
\draw [#1,
       shift={(#2)},
       domain=#3*pi/180:\domain*pi/180,
       variable=\t,
       smooth,
       samples=int(\domain/5)] plot ({\t r}: {#5+\growth*\t-\growth*#3*pi/180})
}

But in this way the spiral growth is linear and the Fermat's spiral has a function of another kind: r(θ)=θ^(1/2), so we just need to adapt the command:

\newcommand\fermatspiral{} % just for safety
\def\fermatspiral[#1](#2)(#3:#4)[#5]{%
% \fermatspiral[options](placement)(start angle:final angle)[revolutions]
\pgfmathsetmacro{\domain}{#4+#5*360}
\draw [#1,
       shift={(#2)},
       domain=#3*pi/180:\domain*pi/180,
       variable=\t,
       smooth,
       samples=int(\domain/5)] plot ({\t r} : {sqrt(\t)})
}

The only Problem is getting the - part, so we can just rotate=180 and we can get both spirals.

MWE

\documentclass{standalone}
\usepackage{tikz}
\newcommand\fermatspiral{} % just for safety
\def\fermatspiral[#1](#2)(#3:#4)[#5]{%
% \fermatspiral[options](placement)(start angle:final angle)[revolutions]
\pgfmathsetmacro{\domain}{#4+#5*360}
\draw [#1,
       shift={(#2)},
       domain=#3*pi/180:\domain*pi/180,
       variable=\t,
       smooth,
       samples=int(\domain/5)] plot ({\t r} : {sqrt(\t)})
}
\begin{document}
\begin{tikzpicture}
\fermatspiral[red](0,0)(0:2)[3]; % Positive part
\fermatspiral[blue, rotate=180](0,0)(0:2)[3]; % Negative part
\end{tikzpicture}
\end{document}

enter image description here

EDIT:

There are three separate questions here, I answered the first and only which hadn't been answered on the website yet. The following answers the other questions, which are: (i) how to fade the path from light color to dark color and (ii) how to place labels on an arbitrary path generated by a function.

To get the path fading from red to dark red it's not that straightfoward as inner color=red, outer color=red!20!black, one has to use path fading like on this wonderful answer by percusse but then you detach the path specification from the filling and some weird things can happen:

\begin{tikzfadingfrompicture}[name=fermat]%
\fermatspiral[transparent!20](0,0)(0:360)[3];
\end{tikzfadingfrompicture}

To get a label somewhere on the path one could use decorations with markings (like in this answer by Jesse), but then again, by using path fading now our path is specified inside the fading option and we can no longer decorate it. Nevertheless, not all is lost, since our path is a well known function we can use \node at (x,f(x)) {}; to specify our label position. So, in summary we can either use path fading and label manually with \node at notation, or we can forget about fading and use decorations to label our path. Since the OP wants to have faded and labeled path the below MWE presents such solution:

Complete MWE

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}%
\newcommand\fermatspiral{} % just for safety
\def\fermatspiral[#1](#2)(#3:#4)[#5]{%
% \fermatspiral[options](placement)(start radius:final radius)[revolutions]
\pgfmathsetmacro{\domain}{#4+#5*360}
\draw [#1,
       shift={(#2)},
       domain=#3*pi/180:\domain*pi/180,
       variable=\t,
       smooth,
       samples=int(\domain/2)] plot ({\t r} : {sqrt(\t)})
}
\begin{tikzfadingfrompicture}[name=fermat]%
\fermatspiral[transparent!20](0,0)(0:360)[3];
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\domain}{4*360}
\path[path fading=fermat, fit fading=false, fading transform={shift={(134:-6.6pt)}}, inner color=red, outer color=red!30!black] circle ({1.1*sqrt(rad(\domain))});
\path[path fading=fermat, fit fading=false, fading transform={rotate=180, shift={(134:-6.6pt)}}, inner color=blue, outer color=blue!30!black] circle ({1.1*sqrt(rad(\domain))});
 \node[right] at ({rad(360) r}:{sqrt(rad(360))}) {A};
 \node[left] at ({rad(360) r}:{-sqrt(rad(360))}) {A};
\end{tikzpicture}
\end{document} 

enter image description here

2

Here's a simple version in Metapost wrapped up in luamplib. Compile with lualatex. (Or strip off the LaTeX header/footer and use plain mpost).

enter image description here

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);

    turns = 5;
    radius = 21;

    path s;     % MP deals in degrees, so \pi/180 \simeq 0.0174533 
    s = origin for t=1 upto 360*turns: -- (radius * sqrt(0.0174533t),0) rotated t endfor;

    path xx, yy;
    xx = (left--right) scaled radius scaled sqrt( 2 * 3.1415926 turns );
    yy = xx rotated 90;

    draw xx withcolor .7 white;
    draw yy withcolor .7 white;

    drawarrow s withcolor 2/3 red;
    drawarrow s rotated 180 withcolor 1/2 blue;

endfig;
\end{mplibcode}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.