Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass{article}
- usepackage{tikz}
- usepgfmodule{nonlineartransformations}
- makeatletter
- defpolartransformation{% from the pgfmanual section 103.4.2
- pgfmathsincos@{pgf@sys@tonumberpgf@x}%
- pgf@x=pgfmathresultxpgf@y%
- pgf@y=pgfmathresultypgf@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.
- begin{tikzpicture}
- begin{scope}[xshift=-4cm]
- draw (-1,0) coordinate (l1) -- (3,1) coordinate (l2);
- end{scope}
- node[circle,draw] (A) at (-1,-2) {A};
- node[circle,draw] (B) at (2,-2) {B};
- draw[blue] (A) -- (l1);
- draw[red] (B) -- (l2);
- 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}
- tikzset{
- transform shape nonlinear/.is choice,
- transform shape nonlinear/.default=true,
- transform shape nonlinear/true/.code=lettikz@nltrelax,
- transform shape nonlinear/false/.code=deftikz@nlt{pgfapproximatenonlineartranslation},
- transform shape nonlinear=false
- }
Add Comment
Please, Sign In to add comment