- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

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
29 class KEYTransformation
30 {
31 public:
34 KEYTransformation();
35
38 KEYTransformation(double xx, double yx, double xy, double yy, double x0, double y0);
39
47 KEYTransformation &operator*=(const KEYTransformation &tr);
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
84 KEYTransformation operator*(const KEYTransformation &left, const KEYTransformation &right);
85
92 bool operator==(const KEYTransformation &left, const KEYTransformation &right);
93
100 bool operator!=(const KEYTransformation &left, const KEYTransformation &right);
101
107 KEYTransformation makeTransformation(const KEYGeometry &geometry);
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
145 KEYTransformation rotate(double angle);
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: */
libetonyek::KEYTransformation::operator*=
KEYTransformation & operator*=(const KEYTransformation &tr)
Apply a transformation on top of this one.
Definition: KEYTransformation.cpp:38
libetonyek::transformations::translate
KEYTransformation translate(const double offsetX, const double offsetY)
Translate along x and/or y axis.
Definition: KEYTransformation.cpp:164
libetonyek::KEYTransformation::m_xx
double m_xx
Definition: KEYTransformation.h:69
y
double y
Definition: KEYShape.cpp:100
libetonyek::operator==
bool operator==(const KEYPath &left, const KEYPath &right)
Definition: KEYPath.cpp:393
libetonyek::KEYTransformation::m_xy
double m_xy
Definition: KEYTransformation.h:71
libetonyek::KEYTransformation::m_x0
double m_x0
Definition: KEYTransformation.h:73
libetonyek::transformations::flip
KEYTransformation flip(const bool horizontal, const bool vertical)
Flip horizontally and/or vertically.
Definition: KEYTransformation.cpp:141
libetonyek::transformations::center
KEYTransformation center(const double width, const double height)
Translate to the center of viewport.
Definition: KEYTransformation.cpp:131
libetonyek::operator!=
bool operator!=(const KEYPath &left, const KEYPath &right)
Definition: KEYPath.cpp:398
libetonyek::transformations::scale
KEYTransformation scale(const double ratioX, const double ratioY)
Scale along x and/or y axis.
Definition: KEYTransformation.cpp:153
libetonyek::KEYTransformation::m_y0
double m_y0
Definition: KEYTransformation.h:74
libetonyek::KEYTransformation::approxEqual
bool approxEqual(const KEYTransformation &other, double eps=KEY_EPSILON) const
Tests for approximate equality of transformations.
Definition: KEYTransformation.cpp:57
libetonyek::transformations::rotate
KEYTransformation rotate(const double angle)
Rotate counterclockwise around origin.
Definition: KEYTransformation.cpp:146
libetonyek::KEY2Token::height
Definition: KEY2Token.h:987
libetonyek::KEY2Token::geometry
Definition: KEY2Token.h:213
x
double x
Definition: KEYShape.cpp:99
libetonyek::makeTransformation
KEYTransformation makeTransformation(const KEYGeometry &geometry)
Create a transformation from a geometry.
Definition: KEYTransformation.cpp:99
libetonyek::operator*
KEYPath operator*(const KEYPath &path, const KEYTransformation &tr)
Create a transformed path.
Definition: KEYPath.cpp:403
libetonyek::KEYTransformation::m_yy
double m_yy
Definition: KEYTransformation.h:72
libetonyek::KEY1Token::angle
Definition: KEY1Token.h:92
KEY_EPSILON
#define KEY_EPSILON
Definition: libetonyek_utils.h:57
libetonyek::KEYTransformation::KEYTransformation
KEYTransformation()
Construct a unit transformation.
Definition: KEYTransformation.cpp:18
libetonyek::KEY2Token::right
Definition: KEY2Token.h:1068
libetonyek::KEY2Token::left
Definition: KEY2Token.h:1014
libetonyek::KEY1Token::width
Definition: KEY1Token.h:176
libetonyek::KEYTransformation::m_yx
double m_yx
Definition: KEYTransformation.h:70
libetonyek::KEYTransformation::operator()
void operator()(double &x, double &y, bool distance=false) const
Apply transformation to a point or distance.
Definition: KEYTransformation.cpp:75
libetonyek::transformations::shear
KEYTransformation shear(const double angleX, const double angleY)
Shear along x and/or y axis.
Definition: KEYTransformation.cpp:158
libetonyek::KEYTransformation
Represents an affine transformation.
Definition: KEYTransformation.h:29
libetonyek::transformations::origin
KEYTransformation origin(const double width, const double height)
Translate from the center of viewport to the origin.
Definition: KEYTransformation.cpp:136
libetonyek_utils.h
libetonyek::KEYGeometry
Definition: KEYTypes.h:45