Guest User

Untitled

a guest
May 26th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. documentclass{article}
  2. usepackage{tikz}
  3. usepgfmodule{nonlineartransformations}
  4. makeatletter
  5. defpolartransformation{% from the pgfmanual section 103.4.2
  6. pgfmathsincos@{pgf@sys@tonumberpgf@x}%
  7. pgf@x=pgfmathresultxpgf@y%
  8. pgf@y=pgfmathresultypgf@y%
  9. } % note that the problem is not specific to this transformation
  10. makeatother
  11. begin{document}
  12. section*{Ordinary linear transformations}
  13. It is well known that one can refer to coordinates inside a scope subject to
  14. linear transformations without problems.
  15.  
  16. begin{tikzpicture}
  17. begin{scope}[xshift=-4cm]
  18. draw (-1,0) coordinate (l1) -- (3,1) coordinate (l2);
  19. end{scope}
  20. node[circle,draw] (A) at (-1,-2) {A};
  21. node[circle,draw] (B) at (2,-2) {B};
  22.  
  23. draw[blue] (A) -- (l1);
  24. draw[red] (B) -- (l2);
  25. end{tikzpicture}
  26.  
  27. section*{Ordinary nonlinear transformations}
  28. This is also true for ``ordinary'' nonlinear transformations.
  29.  
  30. begin{tikzpicture}
  31. begin{scope}
  32. pgftransformnonlinear{polartransformation}
  33. draw (-1,0) coordinate (m1) -- (3,1) coordinate (m2); % no, m does not stand for marmot ;-)
  34. end{scope}
  35. node[circle,draw] (A) at (-1,-2) {A};
  36. node[circle,draw] (B) at (2,-2) {B};
  37. draw[blue] (A) -- (m1);
  38. draw[red] (B) -- (m2);
  39. end{tikzpicture}
  40.  
  41. section*{Nonlinear transformations with texttt{transform shape nonlinear=true}}
  42. However, once one adds texttt{transform shape nonlinear=true}, this does no
  43. longer work.
  44.  
  45.  
  46. begin{tikzpicture}
  47. begin{scope}[transform shape nonlinear=true] % p. 234 of the pgf manual
  48. pgftransformnonlinear{polartransformation}
  49. draw (-1,0) coordinate (r1) -- (3,1) coordinate (r2);
  50. end{scope}
  51. node[circle,draw] (A) at (-1,-2) {A};
  52. node[circle,draw] (B) at (2,-2) {B};
  53. draw[blue] (A) -- (r1);
  54. draw[red] (B) -- (r2);
  55. end{tikzpicture}
  56.  
  57. On the other hand, one might need these things, as only with this option
  58. switched on the shape gets transformed.
  59.  
  60. begin{tikzpicture}[baseline=(A.base)]
  61. begin{scope}
  62. pgftransformnonlinear{polartransformation}
  63. node[draw] (n1) at (2,2){hello!};
  64. end{scope}
  65. node[circle,draw] (A) at (-1,-2) {A};
  66. node[circle,draw] (B) at (2,-2) {B};
  67. draw[blue] (A) -- (n1.west);
  68. draw[red] (B) -- (n1.east);
  69. end{tikzpicture}quad vs.quad
  70. begin{tikzpicture}[baseline=(A.base)]
  71. begin{scope}[transform shape nonlinear=true]
  72. pgftransformnonlinear{polartransformation}
  73. node[draw] (n2) at (2,2){hello!};
  74. end{scope}
  75. node[circle,draw] (A) at (-1,-2) {A};
  76. node[circle,draw] (B) at (2,-2) {B};
  77. draw[blue] (A) -- (n2.west);
  78. draw[red] (B) -- (n2.east);
  79. end{tikzpicture}
  80. end{document}
  81.  
  82. tikzset{
  83. transform shape nonlinear/.is choice,
  84. transform shape nonlinear/.default=true,
  85. transform shape nonlinear/true/.code=lettikz@nltrelax,
  86. transform shape nonlinear/false/.code=deftikz@nlt{pgfapproximatenonlineartranslation},
  87. transform shape nonlinear=false
  88. }
Add Comment
Please, Sign In to add comment