diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2011-10-03 15:09:28 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:25:24 +0300 |
commit | 5d830d56494790a93533a9498c2d81cfd0632848 (patch) | |
tree | a69e336b5f4d163e5d89685a7cda0465f67090d7 /geometry | |
parent | ba7b5963e026d94becb96305d6329a7db430bf30 (diff) |
renamed AARect into AnyRect. renamed corresponding files.
Diffstat (limited to 'geometry')
-rw-r--r-- | geometry/any_rect2d.hpp (renamed from geometry/aa_rect2d.hpp) | 32 | ||||
-rw-r--r-- | geometry/geometry.pro | 2 | ||||
-rw-r--r-- | geometry/geometry_tests/anyrect_test.cpp (renamed from geometry/geometry_tests/aarect_test.cpp) | 36 | ||||
-rw-r--r-- | geometry/geometry_tests/geometry_tests.pro | 2 | ||||
-rw-r--r-- | geometry/geometry_tests/screen_test.cpp | 14 | ||||
-rw-r--r-- | geometry/screenbase.cpp | 8 | ||||
-rw-r--r-- | geometry/screenbase.hpp | 10 |
7 files changed, 52 insertions, 52 deletions
diff --git a/geometry/aa_rect2d.hpp b/geometry/any_rect2d.hpp index e62a9829bd..842e62b959 100644 --- a/geometry/aa_rect2d.hpp +++ b/geometry/any_rect2d.hpp @@ -11,7 +11,7 @@ namespace m2 { /// axis aligned rect template <typename T> - class AARect + class AnyRect { private: @@ -37,17 +37,17 @@ namespace m2 public: - AARect() : m_i(1, 0), m_j(0, 1), m_zero(0, 0), m_rect(){} + AnyRect() : m_i(1, 0), m_j(0, 1), m_zero(0, 0), m_rect(){} /// creating from regular rect - explicit AARect(Rect<T> const & r) + explicit AnyRect(Rect<T> const & r) : m_angle(0), m_i(m_angle.cos(), m_angle.sin()), m_j(-m_angle.sin(), m_angle.cos()), m_zero(r == Rect<T>() ? Point<T>(0, 0) : Point<T>(r.minX(), r.minY())), m_rect(r == Rect<T>() ? Rect<T>() : Rect<T>(0, 0, r.SizeX(), r.SizeY())) { } - AARect(Point<T> const & zero, ang::Angle<T> const & angle, Rect<T> const & r) + AnyRect(Point<T> const & zero, ang::Angle<T> const & angle, Rect<T> const & r) : m_angle(angle), m_i(m_angle.cos(), m_angle.sin()), m_j(-m_angle.sin(), m_angle.cos()), m_zero(Convert(zero, Point<T>(1, 0), Point<T>(0, 1), m_i, m_j)), m_rect(r) @@ -96,7 +96,7 @@ namespace m2 return m_rect.IsPointInside(ConvertTo(pt)); } - bool IsRectInside(AARect<T> const & r) const + bool IsRectInside(AnyRect<T> const & r) const { m2::Point<T> pts[4]; r.GetGlobalPoints(pts); @@ -107,7 +107,7 @@ namespace m2 && m_rect.IsPointInside(pts[3]); } - bool IsIntersect(AARect<T> const & r) const + bool IsIntersect(AnyRect<T> const & r) const { m2::Point<T> pts[4]; if (r.GetLocalRect() == Rect<T>()) @@ -135,7 +135,7 @@ namespace m2 || Intersect(GetLocalRect(), pts[3], pts[0]); } - /// Convert into coordinate system of this AARect + /// Convert into coordinate system of this AnyRect Point<T> const ConvertTo(Point<T> const & p) const { m2::Point<T> i(1, 0); @@ -149,7 +149,7 @@ namespace m2 pts[i] = ConvertTo(pts[i]); } - /// Convert into global coordinates from the local coordinates of this AARect + /// Convert into global coordinates from the local coordinates of this AnyRect Point<T> const ConvertFrom(Point<T> const & p) const { m2::PointD i(1, 0); @@ -196,7 +196,7 @@ namespace m2 m_rect.Inflate(dx, dy); } - void Add(AARect<T> const & r) + void Add(AnyRect<T> const & r) { Point<T> pts[4]; r.GetGlobalPoints(pts); @@ -214,27 +214,27 @@ namespace m2 }; template <typename T> - AARect<T> const Offset(AARect<T> const & r, Point<T> const & pt) + AnyRect<T> const Offset(AnyRect<T> const & r, Point<T> const & pt) { - AARect<T> res(r); + AnyRect<T> res(r); res.Offset(pt); return res; } template <typename T, typename U> - AARect<T> const Inflate(AARect<T> const & r, U const & dx, U const & dy) + AnyRect<T> const Inflate(AnyRect<T> const & r, U const & dx, U const & dy) { - AARect<T> res = r; + AnyRect<T> res = r; res.Inflate(dx, dy); return res; } template <typename T, typename U> - AARect<T> const Inflate(AARect<T> const & r, Point<U> const & pt) + AnyRect<T> const Inflate(AnyRect<T> const & r, Point<U> const & pt) { return Inflate(r, pt.x, pt.y); } - typedef AARect<double> AARectD; - typedef AARect<float> AARectF; + typedef AnyRect<double> AnyRectD; + typedef AnyRect<float> AnyRectF; } diff --git a/geometry/geometry.pro b/geometry/geometry.pro index 35986be65f..08689d8225 100644 --- a/geometry/geometry.pro +++ b/geometry/geometry.pro @@ -35,6 +35,6 @@ HEADERS += \ polygon.hpp \ region2d.hpp \ robust_orientation.hpp \ - aa_rect2d.hpp \ + any_rect2d.hpp \ region2d/binary_operators.hpp \ region2d/boost_concept.hpp \ diff --git a/geometry/geometry_tests/aarect_test.cpp b/geometry/geometry_tests/anyrect_test.cpp index c0c3b1391d..e998fa0108 100644 --- a/geometry/geometry_tests/aarect_test.cpp +++ b/geometry/geometry_tests/anyrect_test.cpp @@ -2,13 +2,13 @@ #include "../../testing/testing.hpp" -#include "../aa_rect2d.hpp" +#include "../any_rect2d.hpp" #include "../../std/cmath.hpp" -UNIT_TEST(AARect_TestConvertTo) +UNIT_TEST(AnyRect_TestConvertTo) { - m2::AARectD r(m2::PointD(0, 0), math::pi / 4, m2::RectD(0, 0, 10, 10)); + m2::AnyRectD r(m2::PointD(0, 0), math::pi / 4, m2::RectD(0, 0, 10, 10)); m2::PointD pt1(100, 0); @@ -16,33 +16,33 @@ UNIT_TEST(AARect_TestConvertTo) TEST(r.ConvertTo(pt1).EqualDxDy(m2::PointD(100 / sqrt2, -100 / sqrt2), 10e-5), ()); TEST(r.ConvertTo(m2::PointD(100, 100)).EqualDxDy(m2::PointD(100 * sqrt2, 0), 10e-5), ()); - m2::AARectD r1(m2::PointD(100, 100), math::pi / 4, m2::RectD(0, 0, 10, 10)); + m2::AnyRectD r1(m2::PointD(100, 100), math::pi / 4, m2::RectD(0, 0, 10, 10)); m2::PointD pt(100, 100 + 50 * sqrt2); TEST(r1.ConvertTo(pt).EqualDxDy(m2::PointD(50, 50), 10e-5), ()); } -UNIT_TEST(AARect_TestConvertFrom) +UNIT_TEST(AnyRect_TestConvertFrom) { - m2::AARectD r(m2::PointD(100, 100), math::pi / 6, m2::RectD(0, 0, 10, 10)); + m2::AnyRectD r(m2::PointD(100, 100), math::pi / 6, m2::RectD(0, 0, 10, 10)); double const sqrt3 = sqrt(3.0); TEST(r.ConvertFrom(m2::PointD(50, 0)).EqualDxDy(m2::PointD(100 + 50 * sqrt3 / 2 , 100 + 50 * 1 / 2.0), 10e-5), ()); TEST(r.ConvertTo(m2::PointD(100 + 50 * sqrt3 / 2, 100 + 50 * 1.0 / 2)).EqualDxDy(m2::PointD(50, 0), 10e-5), ()); } -UNIT_TEST(AARect_ZeroRect) +UNIT_TEST(AnyRect_ZeroRect) { - m2::AARectD r0(m2::RectD(0, 0, 0, 0)); - m2::AARectD r1(m2::Offset(r0, m2::PointD(300.0, 300.0))); - m2::AARectD r2(m2::Inflate(r0, 2.0, 2.0)); + m2::AnyRectD r0(m2::RectD(0, 0, 0, 0)); + m2::AnyRectD r1(m2::Offset(r0, m2::PointD(300.0, 300.0))); + m2::AnyRectD r2(m2::Inflate(r0, 2.0, 2.0)); } -UNIT_TEST(AARect_TestIntersection) +UNIT_TEST(AnyRect_TestIntersection) { - m2::AARectD r0(m2::PointD(93.196, 104.21), 1.03, m2::RectD(2, 0, 4, 15)); - m2::AARectD r1(m2::PointD(99.713, 116.02), -1.03, m2::RectD(0, 0, 14, 14)); + m2::AnyRectD r0(m2::PointD(93.196, 104.21), 1.03, m2::RectD(2, 0, 4, 15)); + m2::AnyRectD r1(m2::PointD(99.713, 116.02), -1.03, m2::RectD(0, 0, 14, 14)); m2::PointD pts[4]; r0.GetGlobalPoints(pts); @@ -55,18 +55,18 @@ UNIT_TEST(AARect_TestIntersection) TEST(r1.GetLocalRect().IsIntersect(r2) == false, ()); } -UNIT_TEST(AARect_TestIsIntersect) +UNIT_TEST(AnyRect_TestIsIntersect) { - m2::AARectD r0(m2::PointD(100, 100), math::pi / 6, m2::RectD(0, 0, 50, 20)); - m2::AARectD r1(m2::PointD(100, 100), math::pi / 6, m2::RectD(0, -10, 50, 10)); - m2::AARectD r2(m2::PointD(100, 100), math::pi / 6, m2::RectD(0, -21, 50, -1)); + m2::AnyRectD r0(m2::PointD(100, 100), math::pi / 6, m2::RectD(0, 0, 50, 20)); + m2::AnyRectD r1(m2::PointD(100, 100), math::pi / 6, m2::RectD(0, -10, 50, 10)); + m2::AnyRectD r2(m2::PointD(100, 100), math::pi / 6, m2::RectD(0, -21, 50, -1)); TEST(r0.IsIntersect(r1), ()); TEST(r1.IsIntersect(r2), ()); TEST(!r0.IsIntersect(r2), ()); TEST(r1.IsIntersect(r2), ()); - m2::AARectD r3(m2::PointD(50, 50), math::pi / 8, m2::RectD(0, 0, 80, 30)); + m2::AnyRectD r3(m2::PointD(50, 50), math::pi / 8, m2::RectD(0, 0, 80, 30)); TEST(r0.IsIntersect(r3), ()); } diff --git a/geometry/geometry_tests/geometry_tests.pro b/geometry/geometry_tests/geometry_tests.pro index 308e54f33c..d1f5428e79 100644 --- a/geometry/geometry_tests/geometry_tests.pro +++ b/geometry/geometry_tests/geometry_tests.pro @@ -36,5 +36,5 @@ SOURCES += \ region_test.cpp \ rect_test.cpp \ robust_test.cpp \ - aarect_test.cpp \ + anyrect_test.cpp \ region2d_binary_op_test.cpp \ diff --git a/geometry/geometry_tests/screen_test.cpp b/geometry/geometry_tests/screen_test.cpp index d2bdd9610a..1cbc78c727 100644 --- a/geometry/geometry_tests/screen_test.cpp +++ b/geometry/geometry_tests/screen_test.cpp @@ -16,7 +16,7 @@ namespace m2::PointD b1(0.0, 0.0); m2::PointD b2(300.0, 300.0); - screen.SetFromRect(m2::AARectD(m2::RectD(b1, b2))); + screen.SetFromRect(m2::AnyRectD(m2::RectD(b1, b2))); b1 = screen.GtoP(b1); b2 = screen.GtoP(b2); @@ -37,7 +37,7 @@ UNIT_TEST(ScreenBase_P2G2P) check_set_from_rect(screen, 500, 1000); screen.OnSize(0, 0, 640, 480); - screen.SetFromRect(m2::AARectD(m2::RectD(-100, -200, 500, 680))); + screen.SetFromRect(m2::AnyRectD(m2::RectD(-100, -200, 500, 680))); /// checking that PtoG(GtoP(p)) == p @@ -55,7 +55,7 @@ UNIT_TEST(ScreenBase_AxisOrientation) ScreenBase screen; screen.OnSize(0, 0, 300, 200); - screen.SetFromRect(m2::AARectD(m2::RectD(0, 0, 300, 200))); + screen.SetFromRect(m2::AnyRectD(m2::RectD(0, 0, 300, 200))); TEST(is_equal(m2::PointD(150, 100), screen.GtoP(m2::PointD(150, 100))), ()); TEST(is_equal(m2::PointD(0, 0), screen.GtoP(m2::PointD(0, 200))), ()); @@ -68,7 +68,7 @@ UNIT_TEST(ScreenBase_X0Y0) { ScreenBase screen; screen.OnSize(10, 10, 300, 200); - screen.SetFromRect(m2::AARectD(m2::RectD(0, 0, 300, 200))); + screen.SetFromRect(m2::AnyRectD(m2::RectD(0, 0, 300, 200))); m2::PointD pxPt = screen.PtoG(m2::PointD(0, 0)); @@ -79,7 +79,7 @@ UNIT_TEST(ScreenBase_ChoosingMaxScale) { ScreenBase screen; screen.OnSize(10, 10, 300, 200); - screen.SetFromRect(m2::AARectD(m2::RectD(0, 0, 200, 400))); + screen.SetFromRect(m2::AnyRectD(m2::RectD(0, 0, 200, 400))); TEST(is_equal(screen.GtoP(m2::PointD(100, 200)), m2::PointD(160, 110)), ()); TEST(is_equal(screen.GtoP(m2::PointD(0, 0)), m2::PointD(110, 210)), ()); @@ -124,11 +124,11 @@ UNIT_TEST(ScreenBase_Rotate) { ScreenBase s; s.OnSize(0, 0, 100, 200); - s.SetFromRect(m2::AARectD(m2::RectD(0, 0, 100, 200))); + s.SetFromRect(m2::AnyRectD(m2::RectD(0, 0, 100, 200))); s.Rotate(math::pi / 4); m2::RectD pxRect = s.PixelRect(); - m2::AARectD glbRect = s.GlobalRect(); + m2::AnyRectD glbRect = s.GlobalRect(); TEST(pxRect == m2::RectD(0, 0, 100, 200), ()); } diff --git a/geometry/screenbase.cpp b/geometry/screenbase.cpp index bdbaa65c44..2f31218c99 100644 --- a/geometry/screenbase.cpp +++ b/geometry/screenbase.cpp @@ -20,7 +20,7 @@ ScreenBase::ScreenBase() : // UpdateDependentParameters(); } -ScreenBase::ScreenBase(m2::RectI const & pxRect, m2::AARectD const & glbRect) +ScreenBase::ScreenBase(m2::RectI const & pxRect, m2::AnyRectD const & glbRect) { OnSize(pxRect); SetFromRect(glbRect); @@ -53,11 +53,11 @@ void ScreenBase::UpdateDependentParameters() double HalfSizeX = PtoG(m2::PointD(m_PixelRect.maxX(), m_PixelRect.Center().y)).Length(PtoG(m2::PointD(m_PixelRect.Center()))); double HalfSizeY = PtoG(m2::PointD(m_PixelRect.Center().x, m_PixelRect.minY())).Length(PtoG(m2::PointD(m_PixelRect.Center()))); - m_GlobalRect = m2::AARectD(m_Org, m_Angle, m2::RectD(-HalfSizeX, -HalfSizeY, HalfSizeX, HalfSizeY)); + m_GlobalRect = m2::AnyRectD(m_Org, m_Angle, m2::RectD(-HalfSizeX, -HalfSizeY, HalfSizeX, HalfSizeY)); m_ClipRect = m_GlobalRect.GetGlobalRect(); } -void ScreenBase::SetFromRect(m2::AARectD const & GlobalRect) +void ScreenBase::SetFromRect(m2::AnyRectD const & GlobalRect) { double hScale = GlobalRect.GetLocalRect().SizeX() / m_PixelRect.SizeX(); double vScale = GlobalRect.GetLocalRect().SizeY() / m_PixelRect.SizeY(); @@ -125,7 +125,7 @@ m2::RectD const & ScreenBase::PixelRect() const return m_PixelRect; } -m2::AARectD const & ScreenBase::GlobalRect() const +m2::AnyRectD const & ScreenBase::GlobalRect() const { return m_GlobalRect; } diff --git a/geometry/screenbase.hpp b/geometry/screenbase.hpp index a50ce0deb7..dc0c9109d2 100644 --- a/geometry/screenbase.hpp +++ b/geometry/screenbase.hpp @@ -2,7 +2,7 @@ #include "point2d.hpp" #include "rect2d.hpp" -#include "aa_rect2d.hpp" +#include "any_rect2d.hpp" #include "../base/math.hpp" @@ -38,7 +38,7 @@ protected: math::Matrix<double, 3, 3> m_PtoG; /// Global Rect - m2::AARectD m_GlobalRect; + m2::AnyRectD m_GlobalRect; /// X-axis aligned global rect used for clipping m2::RectD m_ClipRect; @@ -52,9 +52,9 @@ protected: public: ScreenBase(); - ScreenBase(m2::RectI const & pxRect, m2::AARectD const & glbRect); + ScreenBase(m2::RectI const & pxRect, m2::AnyRectD const & glbRect); - void SetFromRect(m2::AARectD const & rect); + void SetFromRect(m2::AnyRectD const & rect); void SetOrg(m2::PointD const & p); void Move(double dx, double dy); @@ -104,7 +104,7 @@ public: math::Matrix<double, 3, 3> const & PtoGMatrix() const; m2::RectD const & PixelRect() const; - m2::AARectD const & GlobalRect() const; + m2::AnyRectD const & GlobalRect() const; m2::RectD const & ClipRect() const; /// Compute arbitrary pixel transformation, that translates the (oldPt1, oldPt2) -> (newPt1, newPt2) |