# A rather difficult ring like picture to be drawn

I desire a figure similar to the following:

\documentclass[tikz,margin=10pt]{standalone}
\usepackage{mathtools,amssymb}
\begin{document}
\begin{tikzpicture}[scale=2,transform shape]
\draw (1,0) arc (0:90:1);
\draw (-1,0) arc (180:270:1);
\draw[fill=gray!30] (-1,0) -- (-2,0) arc (180:90:2) -- (0,1) arc (90:180:1);
\draw[fill=gray!30] (1,0) -- (2,0) arc (0:-90:2) -- (0,-1) arc (-90:0:1);
\node at (0.2,0.75) {\tiny $\phi^2$};
\node[rotate=50] at (-0.7,0.5) {\tiny $t=0$};
\node[rotate=50] at (0.7,-0.5) {\tiny $t=0$};
\node[rotate=50] at (-1.45,1.2) {\tiny $t=1$};
\node[rotate=50] at (1.45,-1.2) {\tiny $t=1$};
\node[rotate=50] at (-1.6,1.4) {\tiny $\partial \varphi (1)$};
\node[rotate=50] at (1.6,-1.4) {\tiny $\partial \varphi (1)$};
\node at (-2,2) {\tiny $\Omega_1$};
\node at (2,-2) {\tiny $\Omega_2$};
\node at (-1,1) {\tiny $\Delta \mathfrak{M}^2$};
\node at (1,-1) {\tiny $\Delta \mathfrak{M}^2$};
\end{tikzpicture}

\end{document}


as developed here.

However, the figure I desire this time around should be something like the following:

Consider a circle of radius 1. Divide the circle into 60 symmetric arcs. For each arc, starting with the 0-6 degree arc, increase the radius by $.05n$ for n between 1 and 60. so the 354-360 arc should have a radius of .05(60) + 1 =4. Just as in the previous figure, each change in area should be shaded. Here is a sketch of a similar looking object split into 12 arcs:

You can see that each arc has a radius larger than the previous, with the sqwiggles indicating shading and labels $\{ \Omega \}_{i=1}^{n}$, $\phi^2$ and $\partial \varphi$. Any help would be greatly appreciated.

-
Apparently it wasn't so difficult, regarding to the fast answers :) (I'm always amazed how fast and comprehensive the answers here are.) – klingt.net Nov 11 '13 at 9:42

This answer shows two to three approaches:

The first one shows a version where a few often used values are evaluated beforehand and are saved in a macro. Also, the \startAngle and the \endRadius are initialized as the \foreach loop only adds \deltaAngle for the angle and .05 for the radius.

The \foreach loop is then used to iterate over the segments but their number (\iN) is not even used. The nodes are then places using simple math.

The second solution uses my TikZ library qrr.misc which contains a few “fixes” and addition to PGF.

The used additions are the use int key for \foreach that allows us to use arbitrary PGFmath for the \foreach loop and the full arc key as well as the R prefix from PGFmath. The full arc key is similar to the \degrees[<n>] macro from PSTricks. Instead of calculating the angle for the <i>th element of <n> elements (like with the arcAngle function of the third solution) it allows us to specify <i> R in a PGFmath-aware environment. I also added an alternative output. These solutions are probably slower than the first solution because they use more PGfmath and re-evaluate certain values repeatedly (but of course we could use them in \foreach’s evaluate key, too).

The third solution shows an only-PGmath solution that also implements the full arc key via the arcAngle function.

## Code 1

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[declare function={bigR(\n)=\smallR+.05*\n;}]
\newcommand*\smallR{1}
\newcommand*\segments{60}
\pgfmathsetmacro\deltaAngle{360/\segments}
\newcommand*\startAngle{-\deltaAngle}

\foreach \iN[evaluate={
\startAngle=\startAngle+\deltaAngle;
remember=\startAngle] in {1,...,\segments}
-- (\startAngle+\deltaAngle:\smallR)
arc [radius=\smallR, end angle=\startAngle, delta angle=-\deltaAngle] -- cycle;

\node                                                                   {$\phi^2$};
\node at (north west:{sqrt 2 * bigR(\segments/2)})                   {$\{\Omega\}_{i=1}^n$};
\node[rotate=-\deltaAngle/2, right] at (-\deltaAngle/2:bigR \segments) {$\partial \varphi$};
\end{tikzpicture}
\end{document}


## Code 2

\documentclass[tikz]{standalone}
\usetikzlibrary{qrr.misc}
\begin{document}
\begin{tikzpicture}[
declare function={smallR=1; bigR(\n)=smallR+.05*\n; segments=20;},
full arc=segments]% same as \degrees[segments] in PSTricks
\foreach \iN[evaluate={\endRadius=bigR(\iN+1);}, use int=0 to segments-1]
-- (\iN R+1R:smallR)
arc [radius=smallR, end angle=\iN R, delta angle=-1R] -- cycle;

\node                                              {$\phi^2$};
\node at (north west:{sqrt 2 * bigR(segments/2)})  {$\{\Omega\}_{i=1}^n$};
\node[rotate=-.5R, right] at (-.5R: bigR segments) {$\partial \varphi$};
\end{tikzpicture}
\begin{tikzpicture}[
declare function={smallR=1; bigR(\n)=smallR+.05*\n; segments=20;},
full arc=segments]
\filldraw[fill=gray!50] (right:smallR)
\foreach \iN[evaluate={\endRadius=bigR(\iN+1);}, use int=0 to segments-1] {
-- (right:smallR)     arc[radius=smallR, start angle=0, delta angle=-360];

\node                                              {$\phi^2$};
\node at (north west:{sqrt 2 * bigR(segments/2)})  {$\{\Omega\}_{i=1}^n$};
\node[rotate=-.5R, right] at (-.5R: bigR segments) {$\partial \varphi$};
\end{tikzpicture}
\end{document}


## Code 3

\documentclass[tikz]{standalone}
\begin{document}
\foreach \segments in {1,...,60}{
\begin{tikzpicture}[declare function={smallR=1; bigR(\n)=smallR+.05*\n; segments=\segments;
arcAngle(\i,\n)=360/\n*\i;}]
\useasboundingbox (-bigR 45,-bigR 50) rectangle (bigR 60,bigR 45) ++ (right:1.7em);
\foreach \iN[evaluate={
\startAngle=arcAngle(\iN-1, segments);
\endAngle=arcAngle(\iN, segments);
-- (\endAngle:smallR)
arc [radius=smallR, start angle=\endAngle, end angle=\startAngle] -- cycle;
\node {$\phi^2$};
\node at (-{bigR(segments/2)}, {bigR(segments/2)}) {$\{\Omega\}_{i=1}^n$};
\node at ({bigR(segments/2)}, {bigR(segments/2)}) {$n = \segments$};
\node at ({-arcAngle(1, segments)/2}: {bigR(segments)})
[rotate={-arcAngle(1, segments)/2}, right] {$\partial \varphi$};
\end{tikzpicture}}
\end{document}


## Output 3

-
The code ca be written more efficicently, so that PGFmath doesn’t need to evaluate everything again … Is there interest in this kind of outcome? – Qrrbrbirlbel Nov 10 '13 at 22:26
This is the only answer so far that actually does not start with a rectangle of zero height, as the question asks. – Thomas Nov 11 '13 at 1:00
I must have this GIF! – recursion.ninja Nov 11 '13 at 2:58
@Qrrbrbirlbel: I hope you're seriously considering to upload on CTAN your libraries. – Claudio Fiandrino Nov 11 '13 at 7:55
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node,pst-plot}
\def\N{60}
\def\R#1#2{1 3 #1 div #2 mul add}
\begin{document}
\makeatletter
\begin{pspicture}(-2.5,-3.5)(4,2)
\degrees[\N]
\curvepnodes[plotpoints=\numexpr\N+1]{0}{\N}{\R{\N}{t} t \pst@angleunit PtoC}{A}
\multido{\ia=0+1,\ib=1+1}{\N}{\pscustom{\psarc(0,0){!\R{\N}{\ia}}{(A\ia)}{(A\ib)}\psarcn(0,0){1}{(A\ib)}{(A\ia)}\closepath}}
\end{pspicture}
\makeatother
\end{document}


## Animated version

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node,pst-plot}
\def\R#1#2{1 3 #1 div #2 mul add}

\begin{document}
\makeatletter
\multido{\i=1+1}{61}{%
\def\N{\i}
\begin{pspicture}(-2.5,-3.5)(4,2)
\degrees[\N]
\curvepnodes[plotpoints=\numexpr\N+1]{0}{\N}{\R{\N}{t} t \pst@angleunit PtoC}{A}
\multido{\ia=0+1,\ib=1+1}{\N}{\pscustom{\psarc(0,0){!\R{\N}{\ia}}{(A\ia)}{(A\ib)}\psarcn(0,0){1}{(A\ib)}{(A\ia)}\closepath}}
\end{pspicture}}
\makeatother
\end{document}


-
How do you compile this? – Jake Nov 10 '13 at 21:55
@Jake: As usual with latex-dvips-ps2pdf. – kiss my armpit Nov 10 '13 at 21:56
Labeling is not my interest so it is ignored here. – kiss my armpit Nov 10 '13 at 22:09
@Jake Also works with xelatex. – Torbjørn T. Nov 10 '13 at 23:12

Is this something like what you want? Using \foreach:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=2]
\foreach \start in {0, 6, 12, ..., 354}
\draw (\start:1+\start/300) arc (\start:\start+6:1+\start/300);
\foreach \start in {0, 6, 12, ..., 354}
\draw[fill=black!20] (\start:1) -- (\start:1+\start/300) -- (\start+6:1+\start/300) -- (\start+6:1)--cycle;
\draw (357:2.5) node {$\partial \varphi$};
\draw (345:0.5) node {$\varphi^2$};
\draw (150:2) node {$\{ \Omega \}_{i=1}^n$};
\end{tikzpicture}

\end{document}


-
very similar, with the exception of the labels. – Anthony Peter Nov 10 '13 at 21:53
no sir, only the last arc. – Anthony Peter Nov 10 '13 at 21:55
Ah, I understand! – mrc Nov 10 '13 at 22:01

The requirements seem quite specific, so making it customizable seems less of an issue:

\documentclass[tikz,border=0.125cm]{standalone}
\begin{document}
\tikz{
\foreach \a in {0,6,...,354}
\draw [fill=gray!50]
(\a:1) arc (\a:\a+6:1) -- (\a+6:1.05+\a/120) arc (\a+6:\a:1.05+\a/120) -- cycle;
\node {$\phi^2$};
\node at (-3,3) {$\{ \Omega \}_{i=1}^{n}$};
\node [anchor=171] at (357:1.05+357/120) {$\partial \varphi$};
}
\end{document}


And if some customization was required the following still works:

\documentclass[tikz,border=0.125cm]{standalone}
\begin{document}
\tikz{
\def\n{60}
\def\r{1}
\def\f{0.05}
\foreach \i [evaluate={\s=360/\n; \a=\s*\i;}]in {1,2,...,\n}
\draw [fill=gray!50]
(\a:\r) arc (\a:\a-\s:\r) -- (\a-\s:\r+\f*\i) arc (\a-\s:\a:\r+\f*\i) -- cycle;
\node {$\phi^2$};
\node at (135:sqrt 2*1.5*\r+\f*\n/sqrt 2) {$\{ \Omega \}_{i=1}^{n}$};
\node [anchor=180-180/\n] at (-180/\n:\r+\f*\n) {$\partial \varphi$};
}
\end{document}


The result is the same as before (Ok, the \Omega node is 0.00012pt nearer the origin).

Or with a bit of help from gimp:

\documentclass[tikz,border=0.125cm]{standalone}
\def\m{100}
\def\r{1}
\def\f{0.05}
\begin{document}
\foreach\n in {5,...,\m}{
\tikz{
\foreach \i [evaluate={\s=360/\n; \a=\s*\i;}]in {1,2,...,\n}
\draw [fill=gray!50]
(\a:\r) arc (\a:\a-\s:\r) -- (\a-\s:\r+\f*\i) arc (\a-\s:\a:\r+\f*\i) -- cycle;
\node {$\phi^2$};
\node at (135:sqrt 2*\r+sqrt 2*\m*3/8*\f) {$\{ \Omega \}_{i=1}^{\n}$};
\node [anchor=180-180/\n] at (-180/\n:\r+\f*\n) {$\partial \varphi$};
\useasboundingbox (-\r-\m/2*\f,-\r-\m*3/4*\f) rectangle (\r+\m*\f+1,\r+1);
}}
\end{document}


-
Note that the given animation reduced my internet quota by 1.366MB. – kiss my armpit Nov 11 '13 at 16:49
@Marienplatz And yet (at the time of writing) it isn't the largest animated gif on this page. – Mark Wibrow Nov 11 '13 at 18:01