Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaria Volvenkova <d.volvenkova@corp.mail.ru>2015-12-17 18:11:21 +0300
committerDaria Volvenkova <d.volvenkova@corp.mail.ru>2015-12-29 16:42:38 +0300
commitc0dc7744223b5a27f36a82ab26c81a18740f5bc9 (patch)
tree69ac88dad8bc5f2400b921a8f523c0205ff75654 /geometry
parente81c5c1842e541e97ee29ecfa219de0e5d1ef509 (diff)
Unit tests for ScreenBase in perspective added.
Diffstat (limited to 'geometry')
-rw-r--r--geometry/geometry_tests/screen_test.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/geometry/geometry_tests/screen_test.cpp b/geometry/geometry_tests/screen_test.cpp
index 943a8cbe67..f118a70c4e 100644
--- a/geometry/geometry_tests/screen_test.cpp
+++ b/geometry/geometry_tests/screen_test.cpp
@@ -50,6 +50,54 @@ UNIT_TEST(ScreenBase_P2G2P)
TEST(is_equal(pg, screen.PtoG(pp)), ());
}
+UNIT_TEST(ScreenBase_3dTransform)
+{
+ ScreenBase screen;
+
+ double const rotationAngle = math::pi4;
+
+ screen.SetFromRects(m2::AnyRectD(m2::RectD(50, 25, 55, 30)), m2::RectD(0, 0, 200, 400));
+ screen.ApplyPerspective(rotationAngle, rotationAngle, math::pi / 3.0);
+
+ TEST(screen.PixelRectIn3d().SizeX() < screen.PixelRect().SizeX(), ());
+ TEST(screen.PixelRectIn3d().SizeY() < screen.PixelRect().SizeY(), ());
+
+ m2::PointD pp(screen.PixelRect().SizeX() / 2.0, screen.PixelRect().SizeY());
+ m2::PointD p3d = screen.PtoP3d(pp);
+ TEST(p3d.EqualDxDy(m2::PointD(screen.PixelRectIn3d().SizeX() / 2.0, screen.PixelRectIn3d().SizeY()), 1.0e-3), ());
+
+ p3d = m2::PointD(screen.PixelRectIn3d().SizeX() / 2.0, screen.PixelRectIn3d().SizeY() / 2.0);
+ pp = screen.P3dtoP(p3d);
+ TEST(pp.EqualDxDy(m2::PointD(screen.PixelRect().SizeX() / 2.0,
+ screen.PixelRect().SizeY() - screen.PixelRectIn3d().SizeY() / (2.0 * cos(rotationAngle))), 1.0e-3), ());
+
+ p3d = m2::PointD(0, 0);
+ pp = screen.P3dtoP(p3d);
+ TEST(pp.x < 0.001, ());
+
+ p3d = m2::PointD(screen.PixelRectIn3d().SizeX(), 0);
+ pp = screen.P3dtoP(p3d);
+ TEST(fabs(pp.x - screen.PixelRect().maxX()) < 0.001, ());
+}
+
+UNIT_TEST(ScreenBase_P2P3d2P)
+{
+ ScreenBase screen;
+
+ screen.SetFromRects(m2::AnyRectD(m2::RectD(50, 25, 55, 30)), m2::RectD(0, 0, 600, 400));
+ screen.ApplyPerspective(math::pi4, math::pi4, math::pi / 3.0);
+
+ // checking that P3dtoP(PtoP3d(p)) == p
+ m2::PointD pp(500, 300);
+ m2::PointD p3d = screen.PtoP3d(pp);
+ TEST(pp.EqualDxDy(screen.P3dtoP(p3d), 1.0e-3), ());
+
+ // checking that PtoP3(P3dtoP(p)) == p
+ p3d = m2::PointD(400, 300);
+ pp = screen.P3dtoP(p3d);
+ TEST(p3d.EqualDxDy(screen.PtoP3d(pp), 1.0e-3), ());
+}
+
UNIT_TEST(ScreenBase_AxisOrientation)
{
ScreenBase screen;