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