I am trying to rotate a drawing around a specific point using PGF commands. As long as I hard code the center of rotation, this works just fine:
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[style=help lines] (0,0) grid[step=1cm] (3, 3);
% Rotate around (1, 1).
\pgftransformshift{\pgfpointxy{1}{1}}
\pgftransformrotate{20}
\pgftransformshift{\pgfpointxy{-1}{-1}}
\draw (0.5, 0.5) -- (1.5, 1.5);
\draw (1.5, 0.5) -- (0.5, 1.5);
\end{tikzpicture}
\end{document}
But I don't want to rotate around a hard coded center but around a computed one. I compute my center using \coordinate (x) at ($<some computation$);. I tried the following:
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[style=help lines] (0,0) grid[step=1cm] (3, 3);
\coordinate (x) at (1, 1); % In real life: ($<computation>$)
\pgftransformshift{\pgfpointscale{1}{\pgfpointanchor{x}{center}}}
\pgftransformrotate{20}
\pgftransformshift{\pgfpointscale{-1}{\pgfpointanchor{x}{center}}}
\draw (0.5, 0.5) -- (1.5, 1.5);
\draw (1.5, 0.5) -- (0.5, 1.5);
\end{tikzpicture}
\end{document}
Now what seems to happen is that the coordinate specified in the second shift is affected by the preceding \pgftransformrotate, even though I defined it before the transformations. Thus, the drawing is offset in the second example.
Can I somehow prevent my computed center of rotation from being transformed by the pgftransform commands? Or is there any other solution to my problem?



