remove pyxdate and pyxversion, which are not be handled by separate files
[PyX/mjg.git] / manual / trafo.tex
blobf08efad2d8b289fee2914eb9c1433b340d82d055
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
15 \begin{displaymath}
16 \vec{x}' = \mathsf{A}\, \vec{x} + \vec{b}\ ,
17 \end{displaymath}
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{tableii}{l|l}{textrm}{\texttt{trafo} method}{function}
41 \lineii{\texttt{\_\_init\_\_(matrix=((1,0),(0,1)), vector=(0,0)):}}{create new \texttt{trafo} instance with transformation \texttt{matrix} and \texttt{vector}.}
42 \lineii{\texttt{apply(x, y)}}{apply \texttt{trafo} to point vector $(\mathtt{x}, \mathtt{y})$.}
43 \lineii{\texttt{inverse()}}{returns inverse transformation of \texttt{trafo}.}
44 \lineii{\texttt{mirrored(angle)}}{returns \texttt{trafo} followed by mirroring at line through $(0,0)$ with direction \texttt{angle} in degrees.}
45 \lineii{\texttt{rotated(angle, x=None, y=None)}}{returns \texttt{trafo} followed by rotation by \texttt{angle} degrees around point $(\mathtt{x}, \mathtt{y})$, or $(0,0)$, if not given.}
46 \lineii{\texttt{scaled(sx, sy=None, x=None, y=None)}}{returns \texttt{trafo} followed by scaling with scaling factor \texttt{sx} in $x$-direction, \texttt{sy} in $y$-direction ($\mathtt{sy}=\mathtt{sx}$, if not given) with scaling center $(\mathtt{x}, \mathtt{y})$, or $(0,0)$, if not given.}
47 \lineii{\texttt{translated(x, y)}}{returns \texttt{trafo} followed by translation by vector $(\mathtt{x}, \mathtt{y})$.}
48 \lineii{\texttt{slanted(a, angle=0, x=None, y=None)}}{returns \texttt{trafo} followed by XXX}
49 \end{tableii}
50 \medskip
54 \section{Subclasses of trafo}
56 The \verb|trafo| module provides a number of subclasses of
57 the \verb|trafo| class, each of which corresponds to one \verb|trafo|
58 method. They are listed in the following table:
60 \medskip
61 \begin{tableii}{l|l}{textrm}{\texttt{trafo} subclass}{function}
62 \lineii{\texttt{mirror(angle)}}{mirroring at line through $(0,0)$ with direction \texttt{angle} in degrees.}
63 \lineii{\texttt{rotate(angle, x=None, y=None)}}{rotation by \texttt{angle} degrees around point $(\mathtt{x}, \mathtt{y})$, or $(0,0)$, if not given.}
64 \lineii{\texttt{scale(sx, sy=None, x=None, y=None)}}{scaling with scaling factor \texttt{sx} in $x$-direction, \texttt{sy} in $y$-direction ($\mathtt{sy}=\mathtt{sx}$, if not given) with scaling center $(\mathtt{x}, \mathtt{y})$, or $(0,0)$, if not given.}
65 \lineii{\texttt{translate(x, y)}}{translation by vector $(\mathtt{x}, \mathtt{y})$.}
66 \lineii{\texttt{slant(a, angle=0, x=None, y=None)}}{XXX}
67 \end{tableii}
68 \medskip
71 % \section{Examples}
75 %%% Local Variables:
76 %%% mode: latex
77 %%% TeX-master: "manual.tex"
78 %%% End: