I am having problems with transform shape nonlinear=true
option, which can be found on page 123 of the pgfmanual. (Notice that this question was originally part of this earlier question. However, @cfr found out that there are actually two separate issues, and could resolve one of them in this brilliant answer. I still feel that the other issue needs to be reported, so I am posting it here. I'll be happy to remove this post if you feel I should, especially if you are @cfr.) The question is described in this screenshot with the MWE below:
\documentclass{article}
\usepackage{tikz}
\usepgfmodule{nonlineartransformations}
\makeatletter
\def\polartransformation{% from the pgfmanual section 103.4.2
\pgfmathsincos@{\pgf@sys@tonumber\pgf@x}%
\pgf@x=\pgfmathresultx\pgf@y%
\pgf@y=\pgfmathresulty\pgf@y%
} % note that the problem is not specific to this transformation
\makeatother
\begin{document}
\section*{Ordinary linear transformations}
It is well known that one can refer to coordinates inside a scope subject to
linear transformations without problems, regardless of whether or not one installs an
ordinary \texttt{transform shape}.
\begin{tikzpicture}
\begin{scope}[xshift=-4cm]
\draw (-1,0) coordinate (l1) -- (3,1) coordinate (l2);
\end{scope}
\begin{scope}[transform shape]
\draw (-1,0) coordinate (n1) -- (3,1) coordinate (n2);
\end{scope}
\node[circle,draw] (A) at (-1,-2) {A};
\node[circle,draw] (B) at (2,-2) {B};
\draw[blue] (A) -- (l1) (A) -- (n1);
\draw[red] (B) -- (l2) (B) -- (n2);
\end{tikzpicture}
\section*{Ordinary nonlinear transformations}
This is also true for ``ordinary'' nonlinear transformations.
\begin{tikzpicture}
\begin{scope}
\pgftransformnonlinear{\polartransformation}
\draw (-1,0) coordinate (m1) -- (3,1) coordinate (m2); % no, m does not stand for marmot ;-)
\end{scope}
\node[circle,draw] (A) at (-1,-2) {A};
\node[circle,draw] (B) at (2,-2) {B};
\draw[blue] (A) -- (m1);
\draw[red] (B) -- (m2);
\end{tikzpicture}
\section*{Nonlinear transformations with \texttt{transform shape nonlinear=true}}
However, once one adds \texttt{transform shape nonlinear=true}, this does no
longer work.
\begin{tikzpicture}
\begin{scope}[transform shape nonlinear=true] % p. 234 of the pgf manual
\pgftransformnonlinear{\polartransformation}
\draw (-1,0) coordinate (r1) -- (3,1) coordinate (r2);
\end{scope}
\node[circle,draw] (A) at (-1,-2) {A};
\node[circle,draw] (B) at (2,-2) {B};
\draw[blue] (A) -- (r1);
\draw[red] (B) -- (r2);
\end{tikzpicture}
On the other hand, one might need these things, as only with this option
switched on the shape gets transformed.
\begin{tikzpicture}[baseline=(A.base)]
\begin{scope}
\pgftransformnonlinear{\polartransformation}
\node[draw] (n1) at (2,2){hello!};
\end{scope}
\node[circle,draw] (A) at (-1,-2) {A};
\node[circle,draw] (B) at (2,-2) {B};
\draw[blue] (A) -- (n1.west);
\draw[red] (B) -- (n1.east);
\end{tikzpicture}\quad vs.\quad
\begin{tikzpicture}[baseline=(A.base)]
\begin{scope}[transform shape nonlinear=true]
\pgftransformnonlinear{\polartransformation}
\node[draw] (n2) at (2,2){hello!};
\end{scope}
\node[circle,draw] (A) at (-1,-2) {A};
\node[circle,draw] (B) at (2,-2) {B};
\draw[blue] (A) -- (n2.west);
\draw[red] (B) -- (n2.east);
\end{tikzpicture}
\end{document}
Note that this option can be very useful (IMHO).
In the left picture, the coordinates are accessed correctly, but the node shape is not transformed, whereas in the second case the node is transformed, but the coordinates are not accessed correctly. It seems that TikZ does not store the absolute positions of the coordinates correctly.
QUESTION: Is it possible to have TikZ store the absolute coordinates correctly, i.e. just like in all the other cases?
NOTE: The option itself is defined in tikz.code.tex
(and not in pgfmodulenonlineartransformations.code.tex
).
\tikzset{
transform shape nonlinear/.is choice,
transform shape nonlinear/.default=true,
transform shape nonlinear/true/.code=\let\tikz@nlt\relax,
transform shape nonlinear/false/.code=\def\tikz@nlt{\pgfapproximatenonlineartranslation},
transform shape nonlinear=false
}
What seems a bit odd to me is that the default seems to be true
but when TikZ gets loaded it gets set to false.