summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-ext/doc/tikz-ext-manual-en-pgf-trans.tex
blob: b0f0f2906d8dde6d27baf101201410b3fd996723 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
% !TeX spellcheck = en_US
% !TeX root = tikz-ext-manual.tex
% Copyright 2022 by Qrrbrbirlbel
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%

\section{Transformations: Mirroring}
\label{pgflibrary:transformations}

\begin{purepgflibrary}{ext.transformations.mirror}
  This library adds mirror transformations to PGF.
\end{purepgflibrary}

Two approaches to mirror transformation exist:
\begin{enumerate}
\item Using the reflection matrix (see left column).

  This depends on |\pgfpointnormalised|\indexCommandO\pgfpointnormalised which involves
  the sine\indexMathFunctionO{sin} and the cosine\indexMathFunctionO{cos} functions of PGFmath.

\item Using built-in transformations (see right column).

  This depends on |\pgfmathanglebetween|\indexCommandO\pgfmathanglebetween which involves the arctangent (|atan2|\indexMathFunctionO{atan2}) function of PGFmath.
\end{enumerate}

Which one is better? I don't know.
Choose one you're comfortable with.

\begin{paracol}{2}

\subsection{Using the reflection matrix}

The following commands use the reflection matrix that sets the transformation matrix following
\begin{equation*}
  A = \frac{1}{\Vert\vec l\Vert^2} \begin{bmatrix}
  l_x^2-l_y^2 & 2l_xl_y \\
  2l_xl_y & l_y^2-l_x^2\\
  \end{bmatrix}.
\end{equation*}

\switchcolumn% >

\stepcounter{subsection}
\subsection{Using built-in transformations}

The following commands use a combination of shifting, rotating, $-1$ scaling,
rotating back and shifting back to reach the mirror transformation.

The commands are named the same as on the left side,
only the |m| in |mirror| is capitalized.

\switchcolumn*% <

\begin{command}{\pgftransformxmirror\marg{value}}
  Sets up a transformation that mirrors along a vertical line that goes through point $(\text{\meta{value}}, 0)$.

\begin{codeexample}[preamble=\usepgflibrary{transformations.mirror}]
\begin{tikzpicture}
\draw[help lines] (-0.25, -.25) grid (3.25, 1.25);
\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);

\draw[dashed] (1.5, -.25) -- (1.5, 1.25);
\pgftransformxmirror{1.5}

\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
\end{tikzpicture}
\end{codeexample}
\end{command}

\switchcolumn% >

\begin{command}{\pgftransformxMirror\marg{value}}
  Sets up a transformation that mirrors along a vertical line that goes through point $(\text{\meta{value}}, 0)$.

\begin{codeexample}[preamble=\usepgflibrary{transformations.mirror}]
\begin{tikzpicture}
\draw[help lines] (-0.25, -.25) grid (3.25, 1.25);
\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);

\draw[dashed] (1.5, -.25) -- (1.5, 1.25);
\pgftransformxMirror{1.5}

\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
\end{tikzpicture}
\end{codeexample}
\end{command}

\switchcolumn*% <

\begin{command}{\pgftransformymirror\marg{value}}
  Sets up a transformation that mirrors along a horizontal line that goes through point $(0, \text{\meta{value})}$.
\end{command}

\begin{command}{\pgftransformmirror\marg{point A}\marg{point B}}
  Sets up a transformation that mirrors along the line that goes through \meta{point A} and \meta{point B}.
 
\begin{codeexample}[preamble=\usepgflibrary{transformations.mirror}]
\begin{tikzpicture}
\draw[help lines] (-.25, -2.25) grid (2.5, 1.25);
\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);

\draw[dashed] (0, -1) -- (2, 0);
\pgftransformmirror{\pgfpointxy{0}{-1}}
                   {\pgfpointxy{2}{ 0}}

\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
\end{tikzpicture}
\end{codeexample}
\end{command}

\switchcolumn% >

\begin{command}{\pgftransformyMirror\marg{value}}
  Sets up a transformation that mirrors along a horizontal line that goes through point $(0, \text{\meta{value})}$.
\end{command}

\begin{command}{\pgftransformMirror\marg{point A}\marg{point B}}
  Sets up a transformation that mirrors along the line that goes through \meta{point A} and \meta{point B}.
 
\begin{codeexample}[preamble=\usepgflibrary{transformations.mirror}]
\begin{tikzpicture}
\draw[help lines] (-.25, -2.25) grid (2.5, 1.25);
\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);

\draw[dashed] (0, -1) -- (2, 0);
\pgftransformMirror{\pgfpointxy{0}{-1}}
                   {\pgfpointxy{2}{ 0}}

\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
\end{tikzpicture}
\end{codeexample}
\end{command}

\switchcolumn*% <

\begin{command}{\pgfqtransformmirror\marg{point A}}
  Sets up a transformation that mirrors along the line that goes through the origin and \meta{point A}.

\begin{codeexample}[preamble=\usepgflibrary{transformations.mirror}]
\begin{tikzpicture}
\draw[help lines] (-.25, -.25) grid (2.25, 1.25);
\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);

\draw[dashed] (0, 0) -- (2, 1);
\pgfqtransformmirror{\pgfpointxy{2}{1}}

\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
\end{tikzpicture}
\end{codeexample}
\end{command}

\switchcolumn

\begin{command}{\pgfqtransformMirror\marg{point A}}
  Sets up a transformation that mirrors along the line that goes through the origin and \meta{point A}.

\begin{codeexample}[preamble=\usepgflibrary{transformations.mirror}]
\begin{tikzpicture}
\draw[help lines] (-.25, -.25) grid (2.25, 1.25);
\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);

\draw[dashed] (0, 0) -- (2, 1);
\pgfqtransformMirror{\pgfpointxy{2}{1}}

\draw[-latex] (0,0) .. controls (.5,1) .. (1,1);
\end{tikzpicture}
\end{codeexample}
\end{command}

\end{paracol}
\endinput