diff options
author | Alex Zolotarev <deathbaba@gmail.com> | 2010-12-05 19:24:16 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-22 22:33:57 +0300 |
commit | d6e12b7ce4bcbf0ccd1c07eb25de143422913c34 (patch) | |
tree | a7e910c330ce4da9b4f2d8be76067adece2561c4 /geometry/geometry_tests/transformations_test.cpp |
One Month In Minsk. Made in Belarus.
Diffstat (limited to 'geometry/geometry_tests/transformations_test.cpp')
-rw-r--r-- | geometry/geometry_tests/transformations_test.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/geometry/geometry_tests/transformations_test.cpp b/geometry/geometry_tests/transformations_test.cpp new file mode 100644 index 0000000000..e6c1a0fd89 --- /dev/null +++ b/geometry/geometry_tests/transformations_test.cpp @@ -0,0 +1,43 @@ +#include "../../base/SRC_FIRST.hpp" + +#include "../../testing/testing.hpp" +#include "../../base/matrix.hpp" +#include "../../geometry/point2d.hpp" +#include "../transformations.hpp" + +UNIT_TEST(Transformations_Shift) +{ + math::Matrix<double, 3, 3> m = math::Shift(math::Identity<double, 3>(), 200.0, 100.0); + + m2::PointD pt = m2::PointD(30, 20) * m; + + TEST(pt.EqualDxDy(m2::PointD(230, 120), 1.0E-10), ()); +} + +UNIT_TEST(Transformations_ShiftScale) +{ + math::Matrix<double, 3, 3> m = math::Scale(math::Shift(math::Identity<double, 3>(), 100, 100), 2, 3); + m2::PointD pt = m2::PointD(20, 10) * m; + + TEST(pt.EqualDxDy(m2::PointD(240, 330), 1.0E-10), ()); +} + +UNIT_TEST(Transformations_Rotate) +{ + math::Matrix<double, 3, 3> m = math::Rotate(math::Identity<double, 3>(), math::pi / 2); + TEST(m2::PointD(0, 100).EqualDxDy(m2::PointD(100, 0) * m, 1.0E-10), ()); +} + +UNIT_TEST(Transformations_ShiftScaleRotate) +{ + math::Matrix<double, 3, 3> m = math::Rotate(math::Scale(math::Shift(math::Identity<double, 3>(), 100, 100), 2, 3), -math::pi / 2); + m2::PointD pt = m2::PointD(20, 10) * m; + + TEST(pt.EqualDxDy(m2::PointD(330, -240), 1.0E-10), ()); + + math::Matrix<double, 3, 3> invM = math::Inverse(m); + + m2::PointD invPt = m2::PointD(330, -240) * invM; + + TEST(invPt.EqualDxDy(m2::PointD(20, 10), 1.0E-10), ()); +} |