KEYTransformation.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libetonyek project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef KEYTRANSFORMATION_H_INCLUDED
00011 #define KEYTRANSFORMATION_H_INCLUDED
00012 
00013 #include "libetonyek_utils.h"
00014 
00015 namespace libetonyek
00016 {
00017 
00018 struct KEYGeometry;
00019 
00029 class KEYTransformation
00030 {
00031 public:
00034   KEYTransformation();
00035 
00038   KEYTransformation(double xx, double yx, double xy, double yy, double x0, double y0);
00039 
00047   KEYTransformation &operator*=(const KEYTransformation &tr);
00048 
00056   void operator()(double &x, double &y, bool distance = false) const;
00057 
00065   bool approxEqual(const KEYTransformation &other, double eps = KEY_EPSILON) const;
00066 
00067 private:
00068   // transformation matrix
00069   double m_xx;
00070   double m_yx;
00071   double m_xy;
00072   double m_yy;
00073   double m_x0;
00074   double m_y0;
00075 };
00076 
00084 KEYTransformation operator*(const KEYTransformation &left, const KEYTransformation &right);
00085 
00092 bool operator==(const KEYTransformation &left, const KEYTransformation &right);
00093 
00100 bool operator!=(const KEYTransformation &left, const KEYTransformation &right);
00101 
00107 KEYTransformation makeTransformation(const KEYGeometry &geometry);
00108 
00110 namespace transformations
00111 {
00112 
00119 KEYTransformation center(double width, double height);
00120 
00129 KEYTransformation origin(double width, double height);
00130 
00137 KEYTransformation flip(bool horizontal, bool vertical);
00138 
00145 KEYTransformation rotate(double angle);
00146 
00153 KEYTransformation scale(double ratioX, double ratioY);
00154 
00161 KEYTransformation shear(double angleX, double angleY);
00162 
00169 KEYTransformation translate(double offsetX, double offsetY);
00170 
00171 }
00172 
00173 }
00174 
00175 #endif // KEYTRANSFORMATION_H_INCLUDED
00176 
00177 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */