1

I'm currently fiddling around with the pgf library curvilinear. What I want to do is make a shape bending like the shape of a grid, a grid very similar to this one: Canvas transformation of grid to curvilinear grid

One issue however, is that I cannot seem to spawn this grid at a designated place in my tikzpicture. How can I spawn the grid at say, point (0,-5) in my tikzpicture?

So basically, I want to create a flat amount of offset on the nonlinear transformation to then use it as a reference to make a rectangular curve wrapped across the grid (but that shouldn't be too much of an issue).

Code:

\documentclass[landscape,svgnames]{article}
\usepackage[a3paper]{geometry}
\usepackage{tikz}
\usetikzlibrary{fadings,shapes.arrows,shadows,arrows,positioning,shapes}
\usepgflibrary{curvilinear}
\usepgfmodule{nonlineartransformations}

\makeatletter  
\pgfkeys{%
/polargrid/.cd,
rmin/.code ={\global\def\rmin {#1}},
rmax/.code ={\global\def\rmax {#1}},
amin/.code ={\global\def\amin {#1}},
amax/.code ={\global\def\amax {#1}},
rstep/.code={\global\def\rstep{#1}}, 
astep/.code={\global\def\astep{#1}}}

\def\polargrid{\pgfutil@ifnextchar[{\polar@grid}{\polar@grid[]}}%
\def\polar@grid[#1]{%
\pgfkeys{/polargrid/.cd,
rmin ={0},
rmax ={10},
amin ={0},
amax ={180},
rstep={1}, 
astep={10}}   
%
\pgfqkeys{/polargrid}{#1}%
\pgfmathsetmacro{\addastep}{\amin+\astep} 
\pgfmathsetmacro{\addrstep}{\rmin+\rstep} 
 \foreach \a in {\amin,\addastep,...,\amax}  \draw[gray] (\a:\rmin) -- (\a:\rmax);  
 \foreach \r in {\rmin,\addrstep,...,\rmax}  \draw[gray] (\amin:\r cm) arc (\amin:\amax:\r cm);    
 } 
\makeatother  

\begin{document}
\begin{tikzpicture}[scale=2,node distance=1cm, auto,baseline=-.5ex]

\polargrid[rmin=4,rmax=8,amin=180,amax=360] at (5,0)

\end{tikzpicture}
\end{document}
1010011010
  • 6,357
  • I'm not aware of such curvilinear library: could you point the source code? – Claudio Fiandrino Apr 12 '14 at 08:16
  • For solvers: it is described on pages 1060+ in the TikZ3 manual. – Malipivo Apr 12 '14 at 08:23
  • 1
    You need to put things inside a scope to limit the effect then you can shift around that scope. Example; http://tex.stackexchange.com/questions/169624/creating-a-polar-grid-with-tikz/169761#169761 and http://tex.stackexchange.com/a/167109/3235 – percusse Apr 12 '14 at 08:51

1 Answers1

1

Thank you, https://tex.stackexchange.com/users/3235/percusse !

For simple reference you can find the code with the created offset by the scope environment below:

\documentclass[landscape,svgnames]{article}
\usepackage[a3paper]{geometry}
\usepackage{tikz}
\usetikzlibrary{fadings,shapes.arrows,shadows,arrows,positioning,shapes}
\usepgflibrary{curvilinear}
\usepgfmodule{nonlineartransformations}

\makeatletter  
\pgfkeys{%
/polargrid/.cd,
rmin/.code ={\global\def\rmin {#1}},
rmax/.code ={\global\def\rmax {#1}},
amin/.code ={\global\def\amin {#1}},
amax/.code ={\global\def\amax {#1}},
rstep/.code={\global\def\rstep{#1}}, 
astep/.code={\global\def\astep{#1}}}

\def\polargrid{\pgfutil@ifnextchar[{\polar@grid}{\polar@grid[]}}%
\def\polar@grid[#1]{%
\pgfkeys{/polargrid/.cd,
rmin ={0},
rmax ={10},
amin ={0},
amax ={180},
rstep={1}, 
astep={10}}   
%
\pgfqkeys{/polargrid}{#1}%
\pgfmathsetmacro{\addastep}{\amin+\astep} 
\pgfmathsetmacro{\addrstep}{\rmin+\rstep} 
 \foreach \a in {\amin,\addastep,...,\amax}  \draw[gray] (\a:\rmin) -- (\a:\rmax);  
 \foreach \r in {\rmin,\addrstep,...,\rmax}  \draw[gray] (\amin:\r cm) arc (\amin:\amax:\r cm);    
 } 
\makeatother  

\begin{document}
\begin{tikzpicture}[scale=2,node distance=1cm, auto,baseline=-.5ex]

\node (dummy) at (0,-5) {}; % create dummy node

\begin{scope}[remember picture,overlay,shift={(dummy.center)}] %create a shift using the scope environment
\polargrid[rmin=0,rmax=8,amin=180,amax=360]
\end{scope}

\end{tikzpicture}
\end{document}   
1010011010
  • 6,357