Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to draw a curvilinear grid/mesh like this (sorry for freehand drawing) curvilinear grid

I thought the easiest (and most elegant) solution would be to apply a canvas transformation to a regular grid in TikZ.

However, I found only this example in the pgf/TikZ manual, which rotates a grid:

\documentclass{standalone}
\usepackage{pgf}
  \begin{document}
    \begin{pgfpicture}
    \pgftransformrotate{10}
    \pgfpathgrid[stepx=1mm,stepy=2mm]{\pgfpoint{0mm}{0mm}}{\pgfpoint{30mm}{30mm}}
    \pgfusepath{stroke}
  \end{pgfpicture}
\end{document}

rotated grid

Do these kind of transformations exist or should I use the recommended solution in this question on polar grids.

share|improve this question
2  
To my (limited) knowledge, the only transformations that are possible internally are affine and therefore not able to do what you want. As evidence, note that the transformations act on the coordinates and not on the actual paths themselves, so a line stays a line whereas you want that line to transform to an arc. So my thinking is that the polar grid question will be your best bet. –  Loop Space Feb 10 '12 at 8:22

1 Answer 1

Not exactly an answer because I think it's more complicated to transform a tool than to create a new tool. Like Andrew says it's impossible in your case.

Here a macro : ( I made this code in few minutes also I think tikz's expert can do a better macro with more options)

\documentclass{article}
\usepackage{fullpage,tikz} 
\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=.75] 
\polargrid
\end{tikzpicture}  

\begin{tikzpicture}[scale=.75] 
\polargrid[rmin=4,rmax=8,amin=20,amax=120]
\end{tikzpicture}  
\end{document} 

enter image description here

share|improve this answer
    
Beautiful! thanks a lot. –  Sebastian Feb 11 '12 at 5:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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