summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-ext/pgflibrarytransformations.mirror.code.tex
blob: 4d962ccb1cc52c158c1f88318479821db39e82b3 (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
% 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.
%
\def\pgftransformxmirror#1{
  \pgfmathparse{#1}%
  \ifpgfmathunitsdeclared
    \pgf@xa\pgfmathresult pt\relax
    \multiply\pgf@xa2 
    \pgftransformcm{-1}{0}{0}{1}{\pgfqpoint{\pgf@xa}{0pt}}%
  \else
    \pgftransformmirror{\pgfqpointxy{\pgfmathresult}{0}}{\pgfpointadd{\pgfqpointxy{\pgfmathresult}{0}}{\pgfqpointxy{0}{1}}}%
  \fi
}
\def\pgftransformymirror#1{
  \pgfmathparse{#1}%
  \ifpgfmathunitsdeclared
    \pgf@ya\pgfmathresult pt\relax
    \multiply\pgf@ya2
    \pgftransformcm{1}{0}{0}{-1}{\pgfqpoint{0pt}{\pgf@ya}}%
  \else
    \edef\pgf@marshal{\noexpand\pgftransformmirror{\noexpand\pgfqpointxy{0}{\pgfmathresult}}%
                                                  {\noexpand\pgfpointadd{\noexpand\pgfqpointxy{0}{\pgfmathresult}}{\noexpand\pgfqpointxy{1}{0}}}}%
    \pgf@marshal
  \fi}
\def\pgftransformmirror#1#2{%
  \pgfextract@process\pgf@tempa{#1}%
  \pgfpointnormalised{\pgfpointdiff{\pgf@tempa}{#2}}%
  \pgf@xa=\pgf@sys@tonumber\pgf@y\pgf@x
  \pgf@xb=\pgf@sys@tonumber\pgf@x\pgf@x
  \pgf@yb=\pgf@sys@tonumber\pgf@y\pgf@y
  \multiply\pgf@xa2
  \pgf@xc=-\pgf@yb\advance\pgf@xc\pgf@xb
  \pgf@yc=-\pgf@xb\advance\pgf@yc\pgf@yb
  \edef\pgf@temp{{\the\pgf@xc}{+\the\pgf@xa}{+\the\pgf@xa}{+\the\pgf@yc}}%
  \expandafter\pgf@transformcm\pgf@temp{\pgf@tempa}%
  \pgftransformshift{\pgfpointscale{-1}{\pgf@tempa}}%
}

\def\pgfqtransformmirror#1{%
  \pgfpointnormalised{#1}%
  \pgf@xa=\pgf@sys@tonumber\pgf@y\pgf@x
  \pgf@xb=\pgf@sys@tonumber\pgf@x\pgf@x
  \pgf@yb=\pgf@sys@tonumber\pgf@y\pgf@y
  \multiply\pgf@xa2
  \pgf@xc=-\pgf@yb\advance\pgf@xc\pgf@xb
  \pgf@yc=-\pgf@xb\advance\pgf@yc\pgf@yb
  \edef\pgf@temp{{\the\pgf@xc}{+\the\pgf@xa}{+\the\pgf@xa}{+\the\pgf@yc}}%
  \expandafter\pgf@transformcm\pgf@temp{\pgfpointorigin}%
}

% Using existant transformation (shift, rotate, yscale=-1, rotate back, shift back)
\def\pgftransformxMirror#1{
  \pgfmathparse{#1}%
  \ifpgfmathunitsdeclared
    \pgf@xa\pgfmathresult pt\relax
    \multiply\pgf@xa2 
    \pgftransformcm{-1}{0}{0}{1}{\pgfqpoint{\pgf@xa}{0pt}}%
  \else
    \pgftransformMirror{\pgfqpointxy{\pgfmathresult}{0}}{\pgfpointadd{\pgfqpointxy{\pgfmathresult}{0}}{\pgfqpointxy{0}{1}}}%
  \fi
}
\def\pgftransformyMirror#1{
  \pgfmathparse{#1}%
  \ifpgfmathunitsdeclared
    \pgf@ya\pgfmathresult pt\relax
    \multiply\pgf@ya2
    \pgftransformcm{1}{0}{0}{-1}{\pgfqpoint{0pt}{\pgf@ya}}%
  \else
    \edef\pgf@marshal{\noexpand\pgftransformMirror{\noexpand\pgfqpointxy{0}{\pgfmathresult}}%
                                                  {\noexpand\pgfpointadd{\noexpand\pgfqpointxy{0}{\pgfmathresult}}{\noexpand\pgfqpointxy{1}{0}}}}%
    \pgf@marshal
  \fi}

\def\pgftransformMirror#1#2{%
  \pgfextract@process\pgf@tempa{#1}%
  \pgfmathanglebetweenpoints{\pgf@tempa}{#2}%
  \let\pgf@temp\pgfmathresult
  \pgftransformshift{\pgf@tempa}%
  \pgftransformrotate{\pgf@temp}%
  \pgftransformyscale{-1}%
  \pgftransformrotate{-\pgf@temp}%
  \pgftransformshift{\pgfqpointscale{-1}{\pgf@tempa}}%
}

\def\pgfqtransformMirror#1{%
  \pgfmathanglebetweenpoints{\pgfpointorigin}{#1}%
  \let\pgf@temp\pgfmathresult
  \pgftransformrotate{\pgf@temp}%
  \pgftransformyscale{-1}%
  \pgftransformrotate{-\pgf@temp}%
}
\endinput