VectorTransformation2D.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 libmspub 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 __VECTORTRANSFORMATION2D_H__
00011 #define __VECTORTRANSFORMATION2D_H__
00012 
00013 namespace libmspub
00014 {
00015 struct Vector2D
00016 {
00017   double m_x;
00018   double m_y;
00019   Vector2D(double x, double y) : m_x(x), m_y(y)
00020   {
00021   }
00022 };
00023 Vector2D operator+(const Vector2D &l, const Vector2D &r);
00024 Vector2D operator-(const Vector2D &l, const Vector2D &r);
00025 class VectorTransformation2D
00026 {
00027   double m_m11, m_m12, m_m21, m_m22;
00028   double m_x, m_y;
00029 public:
00030   VectorTransformation2D();
00031   Vector2D transform(Vector2D original) const;
00032   Vector2D transformWithOrigin(Vector2D v, Vector2D origin) const;
00033   double getRotation() const;
00034   double getHorizontalScaling() const;
00035   double getVerticalScaling() const;
00036   bool orientationReversing() const;
00037   friend VectorTransformation2D operator*(const VectorTransformation2D &l, const VectorTransformation2D &r);
00038   static VectorTransformation2D fromFlips(bool flipH, bool flipV);
00039   static VectorTransformation2D fromTranslate(double x, double y);
00040   static VectorTransformation2D fromCounterRadians(double theta);
00041 };
00042 VectorTransformation2D operator*(const VectorTransformation2D &l, const VectorTransformation2D &r);
00043 } // namespace libmspub
00044 
00045 #endif /* __VECTORTRANSFORMATION2D_H__ */
00046 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */