~ubuntu-branches/debian/sid/pyx/sid

« back to all changes in this revision

Viewing changes to manual/trafo.rst

  • Committer: Package Import Robot
  • Author(s): Stuart Prescott
  • Date: 2012-12-17 13:45:12 UTC
  • mto: (9.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: package-import@ubuntu.com-20121217134512-q85pr3q75fxii7mq
Tags: upstream-0.12.1
ImportĀ upstreamĀ versionĀ 0.12.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
1
2
.. module:: trafo
2
3
 
3
4
*******************************************
12
13
and mirroring.
13
14
 
14
15
 
15
 
Class trafo
16
 
===========
 
16
Class :class:`trafo`
 
17
====================
17
18
 
18
19
The ``trafo`` class represents a general linear transformation, which is defined
19
 
for a vector :math:`\vec{x}` as  ::
20
 
 
21
 
   XXX: translate this math
22
 
     \vec{x}' = \mathsf{A}\, \vec{x} + \vec{b}\ ,
 
20
for a vector :math:`\vec{x}` as
 
21
 
 
22
.. math::
 
23
 
 
24
   \vec{x}' = \mathsf{A}\, \vec{x} + \vec{b}\ ,
23
25
 
24
26
where :math:`\mathsf{A}` is the transformation matrix and :math:`\vec{b}` the
25
27
translation vector. The transformation matrix must not be singular, *i.e.* we
35
37
:math:`\mathsf{A}^{-1}` of the transformation matrix and the translation vector
36
38
:math:`-\mathsf{A}^{-1}\vec{b}`.
37
39
 
38
 
The methods of the ``trafo`` class are summarized in the following table.
39
 
 
40
 
+-----------------------------------------+----------------------------------------------+
41
 
| ``trafo`` method                        | function                                     |
42
 
+=========================================+==============================================+
43
 
| ``__init__(matrix=((1,0),(0,1)),        | create new ``trafo`` instance with           |
44
 
| vector=(0,0)):``                        | transformation ``matrix`` and ``vector``.    |
45
 
+-----------------------------------------+----------------------------------------------+
46
 
| ``apply(x, y)``                         | apply ``trafo`` to point vector              |
47
 
|                                         | :math:`(\mathtt{x}, \mathtt{y})`.            |
48
 
+-----------------------------------------+----------------------------------------------+
49
 
| ``inverse()``                           | returns inverse transformation of ``trafo``. |
50
 
+-----------------------------------------+----------------------------------------------+
51
 
| ``mirrored(angle)``                     | returns ``trafo`` followed by mirroring at   |
52
 
|                                         | line through :math:`(0,0)` with  direction   |
53
 
|                                         | ``angle`` in degrees.                        |
54
 
+-----------------------------------------+----------------------------------------------+
55
 
| ``rotated(angle, x=None, y=None)``      | returns ``trafo`` followed by rotation by    |
56
 
|                                         | ``angle`` degrees around point               |
57
 
|                                         | :math:`(\mathtt{x}, \mathtt{y})`, or         |
58
 
|                                         | :math:`(0,0)`, if not given.                 |
59
 
+-----------------------------------------+----------------------------------------------+
60
 
| ``scaled(sx, sy=None, x=None, y=None)`` | returns ``trafo`` followed by scaling with   |
61
 
|                                         | scaling factor ``sx`` in :math:`x`\          |
62
 
|                                         | -direction, ``sy`` in :math:`y`\ -direction  |
63
 
|                                         | (:math:`\mathtt{sy}=\mathtt{sx}`, if not     |
64
 
|                                         | given) with scaling center                   |
65
 
|                                         | :math:`(\mathtt{x}, \mathtt{y})`, or         |
66
 
|                                         | :math:`(0,0)`, if not given.                 |
67
 
+-----------------------------------------+----------------------------------------------+
68
 
| ``translated(x, y)``                    | returns ``trafo`` followed by translation by |
69
 
|                                         | vector :math:`(\mathtt{x}, \mathtt{y})`.     |
70
 
+-----------------------------------------+----------------------------------------------+
71
 
| ``slanted(a, angle=0, x=None, y=None)`` | returns ``trafo`` followed by XXX            |
72
 
+-----------------------------------------+----------------------------------------------+
73
 
 
74
 
 
75
 
Subclasses of trafo
76
 
===================
 
40
.. class:: trafo(matrix=((1,0),(0,1)), vector=(0,0))
 
41
 
 
42
   create new ``trafo`` instance with transformation ``matrix`` and ``vector``
 
43
 
 
44
.. method:: apply(x, y)
 
45
 
 
46
   apply ``trafo`` to point vector :math:`(\mathtt{x}, \mathtt{y})`.
 
47
 
 
48
.. method:: inverse()
 
49
 
 
50
   returns inverse transformation of ``trafo``.
 
51
 
 
52
.. method:: mirrored(angle)
 
53
 
 
54
   returns ``trafo`` followed by mirroring at line through :math:`(0,0)` with
 
55
   direction ``angle`` in degrees.
 
56
 
 
57
.. method:: rotated(angle, x=None, y=None)
 
58
 
 
59
   returns ``trafo`` followed by rotation by ``angle`` degrees around point
 
60
   :math:`(\mathtt{x}, \mathtt{y})`, or :math:`(0,0)`, if not given.
 
61
 
 
62
.. method:: scaled(sx, sy=None, x=None, y=None)
 
63
 
 
64
   returns ``trafo`` followed by scaling with scaling factor ``sx`` in
 
65
   :math:`x`\ -direction, ``sy`` in :math:`y`\ -direction
 
66
   (:math:`\mathtt{sy}=\mathtt{sx}`, if not given) with scaling center
 
67
   :math:`(\mathtt{x}, \mathtt{y})`, or :math:`(0,0)`, if not given.
 
68
 
 
69
.. method:: slanted(a, angle=0, x=None, y=None)
 
70
 
 
71
   returns ``trafo`` followed by slant by ``angle`` around point
 
72
   :math:`(\mathtt{x}, \mathtt{y})`, or :math:`(0,0)`, if not given.
 
73
 
 
74
.. method:: translated(x, y)
 
75
 
 
76
   returns ``trafo`` followed by translation by vector :math:`(\mathtt{x}, \mathtt{y})`.
 
77
 
 
78
 
 
79
Subclasses of :class:`trafo`
 
80
============================
77
81
 
78
82
The ``trafo`` module provides a number of subclasses of the ``trafo`` class,
79
 
each of which corresponds to one ``trafo`` method. They are listed in the
80
 
following table:
81
 
 
82
 
+----------------------------------------+----------------------------------------------+
83
 
| ``trafo`` subclass                     | function                                     |
84
 
+========================================+==============================================+
85
 
| ``mirror(angle)``                      | mirroring at line through :math:`(0,0)` with |
86
 
|                                        | direction  ``angle`` in degrees.             |
87
 
+----------------------------------------+----------------------------------------------+
88
 
| ``rotate(angle, x=None, y=None)``      | rotation by ``angle`` degrees around point   |
89
 
|                                        | :math:`(\mathtt{x}, \mathtt{y})`, or         |
90
 
|                                        | :math:`(0,0)`, if not given.                 |
91
 
+----------------------------------------+----------------------------------------------+
92
 
| ``scale(sx, sy=None, x=None, y=None)`` | scaling with scaling factor ``sx`` in        |
93
 
|                                        | :math:`x`\ -direction, ``sy`` in :math:`y`\  |
94
 
|                                        | -direction (:math:`\mathtt{sy}=\mathtt{sx}`, |
95
 
|                                        | if not given) with scaling center            |
96
 
|                                        | :math:`(\mathtt{x}, \mathtt{y})`, or         |
97
 
|                                        | :math:`(0,0)`, if not given.                 |
98
 
+----------------------------------------+----------------------------------------------+
99
 
| ``translate(x, y)``                    | translation by vector :math:`(\mathtt{x},    |
100
 
|                                        | \mathtt{y})`.                                |
101
 
+----------------------------------------+----------------------------------------------+
102
 
| ``slant(a, angle=0, x=None, y=None)``  | XXX                                          |
103
 
+----------------------------------------+----------------------------------------------+
 
83
each of which corresponds to one ``trafo`` method.
 
84
 
 
85
.. class:: mirror(angle)
 
86
 
 
87
   mirroring at line through :math:`(0,0)` with direction ``angle`` in degrees.
 
88
 
 
89
.. class:: rotate(angle, x=None, y=None)
 
90
 
 
91
   rotation by ``angle`` degrees around point :math:`(\mathtt{x}, \mathtt{y})`, or :math:`(0,0)`, if not given.
 
92
 
 
93
.. class:: scale(sx, sy=None, x=None, y=None)
 
94
 
 
95
   scaling with scaling factor ``sx`` in :math:`x`\ -direction, ``sy`` in
 
96
   :math:`y`\ -direction (:math:`\mathtt{sy}=\mathtt{sx}`, if not given) with
 
97
   scaling center :math:`(\mathtt{x}, \mathtt{y})`, or :math:`(0,0)`, if not
 
98
   given.
 
99
 
 
100
.. class:: slant(a, angle=0, x=None, y=None)
 
101
 
 
102
   slant by ``angle`` around point :math:`(\mathtt{x}, \mathtt{y})`, or :math:`(0,0)`, if not given.
 
103
 
 
104
.. class:: translate(x, y)
 
105
 
 
106
   translation by vector :math:`(\mathtt{x}, \mathtt{y})`.
104
107