Question: How to ensure the blue shape of the second picture has same length as the annulus in the first picture?
Context: To illustrate the process of "un-coiling" the annulus after a straight cut. I plan to make an animation with 3 or 4 intermediate steps from "circle" to "line".
\documentclass[border=5mm, varwidth]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tabular}{@{}c@{}}
\begin{tikzpicture}
\filldraw [fill=gray!30, draw=black] (0,0) circle[radius=1];
\filldraw [fill=blue!15, draw=black, even odd rule] (0,0) circle[radius=1] circle[radius=2];
\end{tikzpicture}
\vspace{2cm} \\
\begin{tikzpicture}
\filldraw [fill=gray!30, draw=black] (0,0) circle[radius=1];
\filldraw[fill=blue!15, draw=black, shift={(0,2)}] (330:3) arc (330:210:3) -- (210:4) arc (210:330:4) -- cycle;
\end{tikzpicture}
\end{tabular}
\end{document}
Since the inner circle has radius 1cm and the outer circle radius 2cm, the length of the annulus would be about 3 times pi.
EDIT 1
I am hoping that something could be done with the nonlineartransformations
PGF module. I have seen examples of transformations using polar coordinates and examples using arbitrary transformations. I think what I'm missing are the parametric equations that would flatten a semi-circle into a line. That is, if we forget about the thickness of the annulus and consider a semi-circle starting at (0,0) and ending at (0, 1) anti-clockwise, the transformation is one that would keep the point (0,0) unchanged but would pull (0,1) to the right and eventually down to the (1,0) point. Once I know how to produce the transformation to the rhs semi-circle, I can apply the symmetric transformation to the lhs semi-circle, to complete the circle transformation. And then do that for another pair of semi-circles with a different radius to get the annulus.
EDIT 2
With John Kormylo's suggestions (thanks John!), I was able to write a function that transforms the semi-circle to "flatten" it. Next is to generalize this to a \filldraw
command for an annulus.
\documentclass[margin=3mm,varwidth]{standalone}
\usepackage{tikz}
\makeatletter
\pgfmathdeclarefunction{alpha}{1}{%
\begingroup
\pgfmathparse{180/#1-90}%
\pgf@x=\pgfmathresult pt\relax
\pgfmathreturn\pgf@x
\endgroup
}
\makeatother
\def\shape#1#2{
\draw [draw={#1}] (0,0) arc[start angle=-90, end angle={alpha(#2)}, radius={#2}];
}
\begin{document}
\begin{tikzpicture}[scale=3]
\shape{red}{1}
\shape{red!90}{2}
\shape{red!80}{3}
\shape{red!70}{4}
\shape{red!60}{5}
\shape{red!50}{6}
\shape{red!40}{7}
\shape{red!30}{8}
\shape{red!20}{9}
\shape{black}{100}
\end{tikzpicture}
\end{document}
The left-hand side follows by symmetry. Putting it together yields a somewhat unwieldy function with 6 arguments, including color, center, radius, and angles. This is still not an answer to my original question, so I'm including it here, rather than posting it as an answer. Also, I'm pretty sure the code can be cleaned up.
\documentclass[margin=3mm,varwidth]{standalone}
\usepackage{tikz}
% alpha takes 2 arguments:
% #1: angle of arc, for semi-circle either -180 or 180
% #2: radius of arcs
% #3: rotation of angle
\makeatletter
\pgfmathdeclarefunction{alpha}{3}{%
\begingroup
\pgfmathparse{#1/#2+#3}%
\pgf@x=\pgfmathresult pt\relax
\pgfmathreturn\pgf@x
\endgroup
}
\makeatother
% \shape takes 5 arguments:
% #1: draw color, e.g. red
% #2: center, e.g. (0,0)
% #3: radius
% #4: start angle, e.g. 0 for starting at (1,0), -90 for (0,-1)
% #5: angle of arc, for semi-circle either -180 or 180
% #6: rotation of end angle, e.g. -90 to go from (1,0) to (0,-1)
\def\shape#1#2#3#4#5#6{
\draw [draw={#1}] {#2} arc[radius={#3}, start angle={#4}, end angle={alpha(#6,#3,#5)}];
}
\begin{document}
\begin{tikzpicture}[scale=1.8]
\shape{blue!100}{(0,0)}{1}{-90}{-90}{180}
\shape{blue!100}{(0,0)}{1}{-90}{-90}{-180}
\shape{blue!80}{(0,0)}{2}{-90}{-90}{180}
\shape{blue!80}{(0,0)}{2}{-90}{-90}{-180}
\shape{blue!60}{(0,0)}{6}{-90}{-90}{180}
\shape{blue!60}{(0,0)}{6}{-90}{-90}{-180}
\shape{blue!50}{(0,0)}{150}{-90}{-90}{180}
\shape{blue!50}{(0,0)}{150}{-90}{-90}{-180}
\end{tikzpicture}
\end{document}