KEYTransformation.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libetonyek project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef KEYTRANSFORMATION_H_INCLUDED
11 #define KEYTRANSFORMATION_H_INCLUDED
12 
13 #include "libetonyek_utils.h"
14 
15 namespace libetonyek
16 {
17 
18 struct KEYGeometry;
19 
30 {
31 public:
35 
38  KEYTransformation(double xx, double yx, double xy, double yy, double x0, double y0);
39 
48 
56  void operator()(double &x, double &y, bool distance = false) const;
57 
65  bool approxEqual(const KEYTransformation &other, double eps = KEY_EPSILON) const;
66 
67 private:
68  // transformation matrix
69  double m_xx;
70  double m_yx;
71  double m_xy;
72  double m_yy;
73  double m_x0;
74  double m_y0;
75 };
76 
85 
93 
101 
108 
110 namespace transformations
111 {
112 
119 KEYTransformation center(double width, double height);
120 
129 KEYTransformation origin(double width, double height);
130 
137 KEYTransformation flip(bool horizontal, bool vertical);
138 
146 
153 KEYTransformation scale(double ratioX, double ratioY);
154 
161 KEYTransformation shear(double angleX, double angleY);
162 
169 KEYTransformation translate(double offsetX, double offsetY);
170 
171 }
172 
173 }
174 
175 #endif // KEYTRANSFORMATION_H_INCLUDED
176 
177 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
KEYTransformation & operator*=(const KEYTransformation &tr)
Apply a transformation on top of this one.
Definition: KEYTransformation.cpp:38
KEYTransformation translate(const double offsetX, const double offsetY)
Translate along x and/or y axis.
Definition: KEYTransformation.cpp:164
double m_xx
Definition: KEYTransformation.h:69
double y
Definition: KEYShape.cpp:99
bool operator==(const KEYPath &left, const KEYPath &right)
Definition: KEYPath.cpp:393
double m_xy
Definition: KEYTransformation.h:71
double m_x0
Definition: KEYTransformation.h:73
KEYTransformation flip(const bool horizontal, const bool vertical)
Flip horizontally and/or vertically.
Definition: KEYTransformation.cpp:141
KEYTransformation center(const double width, const double height)
Translate to the center of viewport.
Definition: KEYTransformation.cpp:131
bool operator!=(const KEYPath &left, const KEYPath &right)
Definition: KEYPath.cpp:398
KEYTransformation scale(const double ratioX, const double ratioY)
Scale along x and/or y axis.
Definition: KEYTransformation.cpp:153
double m_y0
Definition: KEYTransformation.h:74
bool approxEqual(const KEYTransformation &other, double eps=KEY_EPSILON) const
Tests for approximate equality of transformations.
Definition: KEYTransformation.cpp:57
KEYTransformation rotate(const double angle)
Rotate counterclockwise around origin.
Definition: KEYTransformation.cpp:146
Definition: KEY2Token.h:986
Definition: KEY2Token.h:213
double x
Definition: KEYShape.cpp:98
KEYTransformation makeTransformation(const KEYGeometry &geometry)
Create a transformation from a geometry.
Definition: KEYTransformation.cpp:99
KEYPath operator*(const KEYPath &path, const KEYTransformation &tr)
Create a transformed path.
Definition: KEYPath.cpp:403
double m_yy
Definition: KEYTransformation.h:72
Definition: KEY1Token.h:92
#define KEY_EPSILON
Definition: libetonyek_utils.h:57
KEYTransformation()
Construct a unit transformation.
Definition: KEYTransformation.cpp:18
Definition: KEY2Token.h:1067
Definition: KEY2Token.h:1013
Definition: KEY1Token.h:176
double m_yx
Definition: KEYTransformation.h:70
void operator()(double &x, double &y, bool distance=false) const
Apply transformation to a point or distance.
Definition: KEYTransformation.cpp:75
KEYTransformation shear(const double angleX, const double angleY)
Shear along x and/or y axis.
Definition: KEYTransformation.cpp:158
Represents an affine transformation.
Definition: KEYTransformation.h:29
KEYTransformation origin(const double width, const double height)
Translate from the center of viewport to the origin.
Definition: KEYTransformation.cpp:136
Definition: KEYTypes.h:45

Generated for libetonyek by doxygen 1.8.5