2

Update

How can I get the shade to vary in the theta direction of the transformed figure rather than left to right? I was hoping the left to right shading in the original rectangle would become a shading in the increasing theta direction! enter image description here

\documentclass{standalone}
\usepackage{tikz}
\usepgfmodule{nonlineartransformations}
\usepgfmodule[nonlineartransformations]

\makeatletter
\def\polartransformation
{
    % \pgf@x will contain the radius
    % \pgf@y will contain the distance
    \pgfmathsincos@{\pgf@sys@tonumber\pgf@x}%
    % pgfmathresultx is now the cosine of radius and
    % pgfmathresulty is the sine of radius
    \pgf@x=\pgfmathresultx\pgf@y%
    \pgf@y=\pgfmathresulty\pgf@y%
}
\makeatother

\begin{document}
    \begin{tikzpicture}

    \draw [black, left color=white, right color=gray ] (3,1) rectangle (7.5,2);
    {
        \pgftransformnonlinear{\polartransformation}
        \pgfsettransformnonlinearflatness{2pt}
        \draw [black, left color=white, right color=gray ] (3,1) rectangle (7.5,2);
    }
    \end{tikzpicture}
\end{document}

Original Problem:

I simply wish to transform this shaded region into an annular one using a polar coordinated transformation. The resulting shaded region should be an annular slice illustrated in the simple diagram (sorry for poor quality). I want the shading to maintain its "orientation". The rectangle is created in the tikz code below with most code taken from the PGF manual.

enter image description here

\documentclass{standalone}
\usepackage{tikz}
\usepgfmodule{nonlineartransformations}
\usepgfmodule[nonlineartransformations]

\def\polartransformation
{
    % \pgf@x will contain the radius
    % \pgf@y will contain the distance
    \pgfmathsincos@{\pgf@sys@tonumber\pgf@x}%
    % pgfmathresultx is now the cosine of radius and
    % pgfmathresulty is the sine of radius
    \pgf@x=\pgfmathresultx\pgf@y%
    \pgf@y=\pgfmathresulty\pgf@y%
}


\begin{document}
    \begin{tikzpicture}

    \draw[black] (0:20mm) arc [start angle=0,end angle = 90, radius=2cm];
    {
        \pgftransformnonlinear{\polartransformation}
        \pgfsettransformnonlinearflatness{2pt}
        \draw [black, left color=white, right color=gray ] (3,3) rectangle (4,3.5);
    }
    \end{tikzpicture}
\end{document}

But here I get the error:

Missing number, treated as zero. ...left color=white, right color=gray ] (3,3)
Dipole
  • 603
  • 8
  • 17
  • This is given in the manual with polartransformation in the nonlinear transformations section – percusse Nov 10 '17 at 20:56
  • OK I will check that - so basically I should be able to define my rectangle in a scope and then apply the transformation to it? – Dipole Nov 10 '17 at 21:09
  • @Cragfelt I think the link may be wrong? – Dipole Nov 11 '17 at 15:01
  • You need to add \makeatletterbefore the definition and \makeatother after the definition of polartransformation to make it work since the macros involve @ character – percusse Nov 11 '17 at 15:14
  • @percusse Ah perfect thank you very much for your input, that solved it! – Dipole Nov 11 '17 at 15:51
  • @Jack You are right, the correct link is this https://tex.stackexchange.com/questions/119911/plot-basic-complex-transformation-in-latex – Cragfelt Nov 11 '17 at 16:09
  • 1
    I updated my question to focus on the shading part now that I can do the transformation – Dipole Nov 11 '17 at 16:35
  • If it is not a predefined shading then you need to write your own unfortunately such as https://tex.stackexchange.com/questions/197864/azimuth-shading – percusse Nov 11 '17 at 21:02
  • @percusse I see! Im a tikz noob but I would have thought that if the shading of the rectangle is defined as a type of contour plot then applying a transform to that will do what I want... Maybe there is a work around. – Dipole Nov 12 '17 at 12:49
  • Shadings are seen through the area defined by the area of the current path. So when you change the shape of the path that you look through it won't change the shading. You have to transform the shading too. – percusse Nov 12 '17 at 12:56

0 Answers0