Debian Codegraph @

texmf-dist/doc/latex/tikz-ext/tikz-ext-manual-en-pgf-trans.tex

raw
1 % !TeX spellcheck = en_US
2 % !TeX root = tikz-ext-manual.tex
3 % Copyright 2022 by Qrrbrbirlbel
4 %
5 % This file may be distributed and/or modified
6 %
7 % 1. under the LaTeX Project Public License and/or
8 % 2. under the GNU Free Documentation License.
9 %
10
11 \section{Transformations: Mirroring}
12 \label{pgflibrary:transformations}
13
14 \begin{purepgflibrary}{ext.transformations.mirror}
15 This library adds mirror transformations to \pgfname.
16 \end{purepgflibrary}
17
18 Two approaches to mirror transformation exist:
19 \begin{enumerate}
20 \item Using the reflection matrix (see left column).
21
22 This depends on |\pgfpointnormalised|\indexCommandO\pgfpointnormalised which involves
23 the sine\indexMathFunctionO{sin} and the cosine\indexMathFunctionO{cos} functions of \pgfname math.
24
25 \item Using built-in transformations (see right column).
26
27 This depends on |\pgfmathanglebetweenpoints|\indexCommandO\pgfmathanglebetweenpoints which
28 involves the arctangent (|atan2|\indexMathFunctionO{atan2}) function of \pgfname math.
29 \end{enumerate}
30
31 Which one is better? I don't know.
32 Choose one you're comfortable with.
33
34 \begin{paracol}{2}
35
36 \subsection{Using the reflection matrix}
37
38 The following commands use the reflection matrix that sets the transformation matrix following
39 \begin{equation*}
40 A = \frac{1}{\Vert\vec l\Vert^2} \begin{bmatrix}
41 l_x^2-l_y^2 & 2l_xl_y \\
42 2l_xl_y & l_y^2-l_x^2\\
43 \end{bmatrix}.
44 \end{equation*}
45
46 \switchcolumn% >
47
48 \stepcounter{subsection}
49 \subsection{Using built-in transformations}
50
51 The following commands use a combination of shifting, rotating, $-1$ scaling,
52 rotating back and shifting back to reach the mirror transformation.
53
54 The commands are named the same as on the left side,
55 only the |m| in |mirror| is capitalized.
56
57 \switchcolumn*% <
58
59 \begin{command}{\pgfexttransformxmirror\marg{value}}\cmdcompat\pgftransformxmirror
60 Sets up a transformation that mirrors along a vertical line that goes through point $(\text{\meta{value}}, 0)$.
61
62 \begin{codeexample}[preamble=\usepgflibrary{ext.transformations.mirror}]
63 \begin{tikzpicture}
64 \draw[help lines] (-.25, -.25) grid (3.25, 1.25);
65 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
66
67 \draw[dashed] (1.5, -.25) -- (1.5, 1.25);
68 \pgfexttransformxmirror{1.5}
69
70 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
71 \end{tikzpicture}
72 \end{codeexample}
73 \end{command}
74
75 \switchcolumn% >
76
77 \begin{command}{\pgfexttransformxMirror\marg{value}}\cmdcompat\pgftransformxMirror
78 Sets up a transformation that mirrors along a vertical line that goes through point $(\text{\meta{value}}, 0)$.
79
80 \begin{codeexample}[preamble=\usepgflibrary{ext.transformations.mirror}]
81 \begin{tikzpicture}
82 \draw[help lines] (-.25, -.25) grid (3.25, 1.25);
83 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
84
85 \draw[dashed] (1.5, -.25) -- (1.5, 1.25);
86 \pgfexttransformxMirror{1.5}
87
88 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
89 \end{tikzpicture}
90 \end{codeexample}
91 \end{command}
92
93 \switchcolumn*% <
94
95 \begin{command}{\pgfexttransformymirror\marg{value}}\cmdcompat\pgftransformymirror
96 Sets up a transformation that mirrors along a horizontal line that goes through point $(0, \text{\meta{value})}$.
97 \end{command}
98
99 \begin{command}{\pgfexttransformmirror\marg{point A}\marg{point B}}\cmdcompat\pgftransformmirror
100 Sets up a transformation that mirrors along the line that goes through \meta{point A} and \meta{point B}.
101
102 \begin{codeexample}[preamble=\usepgflibrary{ext.transformations.mirror}]
103 \begin{tikzpicture}
104 \draw[help lines] (-.25, -2.25) grid (2.5, 1.25);
105 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
106
107 \draw[dashed] (0, -1) -- (2, 0);
108 \pgfexttransformmirror{\pgfpointxy{0}{-1}}
109 {\pgfpointxy{2}{ 0}}
110
111 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
112 \end{tikzpicture}
113 \end{codeexample}
114 \end{command}
115
116 \switchcolumn% >
117
118 \begin{command}{\pgfexttransformyMirror\marg{value}}\cmdcompat\pgftransformyMirror
119 Sets up a transformation that mirrors along a horizontal line that goes through point $(0, \text{\meta{value})}$.
120 \end{command}
121
122 \begin{command}{\pgfexttransformMirror\marg{point A}\marg{point B}}\cmdcompat\pgftransformMirror
123 Sets up a transformation that mirrors along the line that goes through \meta{point A} and \meta{point B}.
124
125 \begin{codeexample}[preamble=\usepgflibrary{ext.transformations.mirror}]
126 \begin{tikzpicture}
127 \draw[help lines] (-.25, -2.25) grid (2.5, 1.25);
128 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
129
130 \draw[dashed] (0, -1) -- (2, 0);
131 \pgfexttransformMirror{\pgfpointxy{0}{-1}}
132 {\pgfpointxy{2}{ 0}}
133
134 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
135 \end{tikzpicture}
136 \end{codeexample}
137 \end{command}
138
139 \switchcolumn*% <
140
141 \begin{command}{\pgfextqtransformmirror\marg{point A}}\cmdcompat\pgfqtransformmirror
142 Sets up a transformation that mirrors along the line that goes through the origin and \meta{point A}.
143
144 \begin{codeexample}[preamble=\usepgflibrary{ext.transformations.mirror}]
145 \begin{tikzpicture}
146 \draw[help lines] (-.25, -.25) grid (2.25, 1.25);
147 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
148
149 \draw[dashed] (0, 0) -- (2, 1);
150 \pgfextqtransformmirror{\pgfpointxy{2}{1}}
151
152 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
153 \end{tikzpicture}
154 \end{codeexample}
155 \end{command}
156
157 \switchcolumn
158
159 \begin{command}{\pgfextqtransformMirror\marg{point A}}\cmdcompat\pgfqtransformMirror
160 Sets up a transformation that mirrors along the line that goes through the origin and \meta{point A}.
161
162 \begin{codeexample}[preamble=\usepgflibrary{ext.transformations.mirror}]
163 \begin{tikzpicture}
164 \draw[help lines] (-.25, -.25) grid (2.25, 1.25);
165 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
166
167 \draw[dashed] (0, 0) -- (2, 1);
168 \pgfextqtransformMirror{\pgfpointxy{2}{1}}
169
170 \draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
171 \end{tikzpicture}
172 \end{codeexample}
173 \end{command}
174
175 \end{paracol}
176 \endinput