#pragma once #include "geometry/point2d.hpp" #include "base/matrix.hpp" /// v` = v * M, v = [x, y, 1] namespace math { template Matrix const Rotate(Matrix const & m, U const & cos, U const & sin) { Matrix m1 = Identity(); m1(0, 0) = cos; m1(0, 1) = sin; m1(1, 0) = -sin; m1(1, 1) = cos; return m * m1; } template Matrix const Rotate(Matrix const & m, U const & angle) { return Rotate(m, cos(angle), sin(angle)); } template Matrix const Shift(Matrix const & m, U const & dx, U const & dy) { Matrix m1 = Identity(); m1(2, 0) = dx; m1(2, 1) = dy; return m * m1; } template Matrix const Shift(Matrix const & m, m2::Point const & pt) { return Shift(m, pt.x, pt.y); } template Matrix const Scale(Matrix const & m, U const & kx, U const & ky) { Matrix m1 = Identity(); m1(0, 0) = kx; m1(1, 1) = ky; return m * m1; } template Matrix const Scale(Matrix const & m, m2::Point const & pt) { return Scale(m, pt.x, pt.y); } }