we missed something, namely to update the CHANGES file...
[PyX/mjg.git] / manual / trafo.tex
blob498c570517a9f0a32a568b31029ef766a675944f
1 \chapter{Module trafo: linear transformations}
3 \label{trafo}
5 With the \verb|trafo| module \PyX\ supports linear transformations, which can
6 then be applied to canvases, B\'ezier paths and other objects. It consists
7 of the main class \verb|trafo| representing a general linear
8 transformation and subclasses thereof, which provide special operations
9 like translation, rotation, scaling, and mirroring.
11 \section{Class trafo}
13 The \verb|trafo| class represents a general linear
14 transformation, which is defined for a vector $\vec{x}$ as
16 \vec{x}' = \mathsf{A}\, \vec{x} + \vec{b}\ ,
18 where $\mathsf{A}$ is the transformation matrix and $\vec{b}$ the
19 translation vector. The transformation matrix must not be singular,
20 \textit{i.e.} we require $\det \mathsf{A} \ne 0$.
24 Multiple \verb|trafo| instances can be multiplied, corresponding to a
25 consecutive application of the respective transformation. Note that
26 \verb|trafo1*trafo2| means that \verb|trafo1| is applied after
27 \verb|trafo2|, \textit{i.e.} the new transformation is given
28 by $\mathsf{A} = \mathsf{A}_1 \mathsf{A}_2$ and
29 $\vec{b} = \mathsf{A}_1 \vec{b}_2 + \vec{b}_1$. Use the \verb|trafo|
30 methods described below, if you prefer thinking the other way round.
31 The inverse of a transformation can be obtained via the \verb|trafo|
32 method \verb|inverse()|, defined by the inverse $\mathsf{A}^{-1}$ of
33 the transformation matrix and the translation vector
34 $-\mathsf{A}^{-1}\vec{b}$.
36 The methods of the \verb|trafo| class are summarized in the following
37 table.
39 \medskip
40 \begin{tabularx}{\linewidth}{>{\hsize=.8\hsize}X>{\raggedright\arraybackslash\hsize=1.2\hsize}X}
41 \texttt{trafo} method & function \\
42 \hline
43 \texttt{\_\_init\_\_(matrix=((1,0),(0,1)),\newline
44 \phantom{\_\_init\_\_(}vector=(0,0)):} & create new \texttt{trafo}
45 instance with transformation \texttt{matrix} and \texttt{vector}.
47 \texttt{apply(x, y)} & apply \texttt{trafo} to point vector
48 $(\mathtt{x}, \mathtt{y})$.\\
49 \texttt{inverse()} & returns inverse transformation of
50 \texttt{trafo}.\\
51 \texttt{mirrored(angle)} & returns \texttt{trafo} followed by mirroring
52 at line through $(0,0)$ with direction \texttt{angle} in degrees.\\
53 \texttt{rotated(angle, \newline\phantom{rotate(}x=None, y=None)} &
54 returns \texttt{trafo} followed by rotation by \texttt{angle} degrees
55 around point $(\mathtt{x},
56 \mathtt{y})$, or $(0,0)$, if not given.\\
57 \texttt{scaled(sx, sy=None,\newline\phantom{scale(}x=None, y=None)} &
58 returns \texttt{trafo} followed by
59 scaling with scaling factor \texttt{sx} in $x$-direction, \texttt{sy} in
60 $y$-direction ($\mathtt{sy}=\mathtt{sx}$, if not given) with scaling
61 center $(\mathtt{x}, \mathtt{y})$, or $(0,0)$, if not given.\\
62 \texttt{translated(x, y)} & returns \texttt{trafo} followed by
63 translation by vector $(\mathtt{x}, \mathtt{y})$.\\
64 \texttt{slanted(a, angle=0, x=None, y=None)} & returns \texttt{trafo}
65 followed by XXX\\
66 \end{tabularx}
67 \medskip
71 \section{Subclasses of trafo}
73 The \verb|trafo| module provides a number of subclasses of
74 the \verb|trafo| class, each of which corresponds to one \verb|trafo|
75 method. They are listed in the following table:
77 \medskip
78 \begin{tabularx}{\linewidth}{>{\hsize=.7\hsize}X>{\raggedright\arraybackslash\hsize=1.3\hsize}X}
79 \texttt{trafo} subclass & function \\
80 \hline
81 \texttt{mirror(angle)} & mirroring at line through $(0,0)$
82 with direction \texttt{angle} in degrees.\\
83 \texttt{rotate(angle, \newline\phantom{rotation(}x=None, y=None)} &
84 rotation by \texttt{angle} degrees around point $(\mathtt{x},
85 \mathtt{y})$, or $(0,0)$, if not given.\\
86 \texttt{scale(sx, sy=None,\newline\phantom{scaling(}x=None, y=None)} &
87 scaling with scaling factor \texttt{sx} in $x$-direction,
88 \texttt{sy} in $y$-direction ($\mathtt{sy}=\mathtt{sx}$, if not
89 given) with scaling
90 center $(\mathtt{x}, \mathtt{y})$, or $(0,0)$, if not given.\\
91 \texttt{translate(x, y)} &
92 translation by vector $(\mathtt{x}, \mathtt{y})$.\\
93 \texttt{slant(a, angle=0, x=None, y=None)} & XXX \\
94 \end{tabularx}
95 \medskip
98 % \section{Examples}
102 %%% Local Variables:
103 %%% mode: latex
104 %%% TeX-master: "manual.tex"
105 %%% End: