+ class Transformation : public glm::mat2 + { + public: + bool is_null() const { return const_mat() == glm::mat2(); } + void reset() { mat() = glm::mat2(); } + void orient(MirOrientation ori) + { + int cos, sin; + switch (ori) + { + case mir_orientation_normal: sin = 0; cos = 1; break; + case mir_orientation_left: sin = 1; cos = 0; break; + case mir_orientation_inverted: sin = 0; cos = -1; break; + case mir_orientation_right: sin = -1; cos = 0; break; + } + mat() = glm::mat2(cos, sin, -sin, cos) * mat(); + } + void mirror(MirMirrorMode mode) + { + int x = 1, y = 1; + if (mode == mir_mirror_mode_horizontal) + x = -1; + else if (mode == mir_mirror_mode_vertical) + y = -1; + mat() = glm::mat2(x, 0, 0, y) * mat(); + } + private: + glm::mat2 const& const_mat() const { return *this; } + glm::mat2& mat() { return *this; } + };
Doesn't look like something that belongs in a public header file.
Mostly it seems replaceable by a free function:
auto transform_for(MirOrientation orientation) -> glm::mat2;
« Back to merge proposal
+ class Transformation : public glm::mat2 MirOrientation ori) _normal: sin = 0; cos = 1; break; _left: sin = 1; cos = 0; break; _inverted: sin = 0; cos = -1; break; _right: sin = -1; cos = 0; break; MirMirrorMode mode) mode_horizontal ) mode_vertical)
+ {
+ public:
+ bool is_null() const { return const_mat() == glm::mat2(); }
+ void reset() { mat() = glm::mat2(); }
+ void orient(
+ {
+ int cos, sin;
+ switch (ori)
+ {
+ case mir_orientation
+ case mir_orientation
+ case mir_orientation
+ case mir_orientation
+ }
+ mat() = glm::mat2(cos, sin, -sin, cos) * mat();
+ }
+ void mirror(
+ {
+ int x = 1, y = 1;
+ if (mode == mir_mirror_
+ x = -1;
+ else if (mode == mir_mirror_
+ y = -1;
+ mat() = glm::mat2(x, 0, 0, y) * mat();
+ }
+ private:
+ glm::mat2 const& const_mat() const { return *this; }
+ glm::mat2& mat() { return *this; }
+ };
Doesn't look like something that belongs in a public header file.
Mostly it seems replaceable by a free function:
auto transform_ for(MirOrientat ion orientation) -> glm::mat2;