Code

German translation update
[inkscape.git] / src / libnr / nr-rotate.h
1 #ifndef SEEN_NR_ROTATE_H
2 #define SEEN_NR_ROTATE_H
4 /** \file
5  * Rotation about the origin.
6  */
8 #include <libnr/nr-point.h>
9 #include <libnr/nr-point-fns.h>
10 #include <libnr/nr-point-ops.h>
12 namespace NR {
14 /** Notionally an NR::Matrix corresponding to rotation about the origin.
15     Behaves like NR::Matrix for multiplication.
16 **/
17 class rotate {
18 public:
19     Point vec;
21 private:
22     rotate();
24 public:
25     explicit rotate(Coord theta);
26     explicit rotate(Point const &p) : vec(p) {}
27     explicit rotate(Coord const x, Coord const y) : vec(x, y) {}
29     bool operator==(rotate const &o) const {
30         return vec == o.vec;
31     }
33     bool operator!=(rotate const &o) const {
34         return vec != o.vec;
35     }
37     inline rotate &operator*=(rotate const &b);
38     /* Defined in nr-rotate-ops.h. */
40     rotate inverse() const {
41         /** \todo
42          * In the usual case that vec is a unit vector (within rounding error),
43          * dividing by len_sq is either a noop or numerically harmful. 
44          * Make a unit_rotate class (or the like) that knows its length is 1.
45          */
46         double const len_sq = dot(vec, vec);
47         return rotate( Point(vec[X], -vec[Y])
48                        / len_sq );
49     }
50 };
52 } /* namespace NR */
55 #endif /* !SEEN_NR_ROTATE_H */
57 /*
58   Local Variables:
59   mode:c++
60   c-file-style:"stroustrup"
61   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
62   indent-tabs-mode:nil
63   fill-column:99
64   End:
65 */
66 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :