Code

58e06fc6de032e40e0ba0de1c12f81309979be6a
[inkscape.git] / src / libnr / nr-point-matrix-ops.h
1 /** \file operator functions over (NR::Point, NR::Matrix). */
2 #ifndef SEEN_NR_POINT_MATRIX_OPS_H
3 #define SEEN_NR_POINT_MATRIX_OPS_H
5 #include "libnr/nr-point.h"
6 #include "libnr/nr-matrix.h"
8 namespace NR {
10 inline Point operator*(Point const &v, Matrix const &m)
11 {
12 #if 1  /* Which code makes it easier to see what's happening? */
13     NR::Point const xform_col0(m[0],
14                                m[2]);
15     NR::Point const xform_col1(m[1],
16                                m[3]);
17     NR::Point const xlate(m[4], m[5]);
18     return ( Point(dot(v, xform_col0),
19                    dot(v, xform_col1))
20              + xlate );
21 #else
22     return Point(v[X] * m[0]  +  v[Y] * m[2]  +  m[4],
23                  v[X] * m[1]  +  v[Y] * m[3]  +  m[5]);
24 #endif
25 }
27 inline Point &Point::operator*=(Matrix const &m)
28 {
29     *this = *this * m;
30     return *this;
31 }
33 } /* namespace NR */
36 #endif /* !SEEN_NR_POINT_MATRIX_OPS_H */
38 /*
39   Local Variables:
40   mode:c++
41   c-file-style:"stroustrup"
42   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
43   indent-tabs-mode:nil
44   fill-column:99
45   End:
46 */
47 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :