diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2011-10-08 19:55:50 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:25:39 +0300 |
commit | c08a25cd6a99a73fe772493f5a97e3021d5676ae (patch) | |
tree | f7f7773303172b450dacfb75bc124a2bb827fc50 /geometry | |
parent | fece0be4bae34ee7ebed23a11b650813ff94914b (diff) |
added correct transformation of PathTextElements during rendering with non-identity Matrix.
Diffstat (limited to 'geometry')
-rw-r--r-- | geometry/angles.hpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/geometry/angles.hpp b/geometry/angles.hpp index 8a53474d5f..ba0ed7bcd3 100644 --- a/geometry/angles.hpp +++ b/geometry/angles.hpp @@ -3,6 +3,7 @@ #include <cmath> #include "point2d.hpp" +#include "../base/matrix.hpp" #include "../base/start_mem_debug.hpp" namespace ang @@ -36,11 +37,38 @@ namespace ang { return m_cos; } + + Angle<T> const & operator*=(math::Matrix<T, 3, 3> const & m) + { + m2::Point<T> pt0(0, 0); + m2::Point<T> pt1(m_cos, m_sin); + + pt1 *= m; + pt0 *= m; + + m_val = atan2(pt1.y - pt0.y, pt1.x - pt0.x); + m_sin = sin(m_val); + m_cos = cos(m_val); + + return this; + } }; typedef Angle<double> AngleD; typedef Angle<float> AngleF; + template <typename T> + Angle<T> const operator*(Angle<T> const & a, math::Matrix<T, 3, 3> const & m) + { + m2::Point<T> pt0(0, 0); + m2::Point<T> pt1(a.cos(), a.sin()); + + pt1 *= m; + pt0 *= m; + + return Angle<T>(atan2(pt1.y - pt0.y, pt1.x - pt0.x)); + } + /// Returns an angle of vector [p1, p2] from x-axis directed to y-axis. /// Angle is in range [-pi, pi]. template <typename T> |