[dasher] Fix xmap/ixmap to be inverses, add test code



commit e7a5ed57b965e63436cc6aefc546778d7a2beb42
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Mon Dec 13 16:59:45 2010 +0000

    Fix xmap/ixmap to be inverses, add test code

 Src/DasherCore/DasherViewSquare.cpp |   20 ++++++++++++++++++++
 Src/DasherCore/DasherViewSquare.inl |    2 +-
 2 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/Src/DasherCore/DasherViewSquare.cpp b/Src/DasherCore/DasherViewSquare.cpp
index 7581040..1fc2af5 100644
--- a/Src/DasherCore/DasherViewSquare.cpp
+++ b/Src/DasherCore/DasherViewSquare.cpp
@@ -896,6 +896,26 @@ void CDasherViewSquare::SetScaleFactor( void )
     m_dXmpc = std::min(1.0,0.9 * dScaleFactorX / dScaleFactorY);
   }
   iCenterX *= m_dXmpc;
+  
+#ifdef DEBUG
+  //now test Dasher2Screen & Screen2Dasher are inverses...
+  for (screenint x=0; x<iScreenWidth; x++) {
+    dasherint dx, dy;
+    Screen2Dasher(x, 0, dx, dy);
+    screenint fx, fy;
+    Dasher2Screen(dx, dy, fx, fy);
+    if (fx!=x)
+      std::cout << "ERROR ScreenX " << x << " becomes " << dx << " back to " << fx << std::endl;;
+  }
+  for (screenint y=0; y<iScreenHeight; y++) {
+    dasherint dx,dy;
+    Screen2Dasher(0, y, dx, dy);
+    screenint fx,fy;
+    Dasher2Screen(dx, dy, fx, fy);
+    if (fy!=y)
+      std::cout << "ERROR ScreenY " << y << " becomes " << dy << " back to " << fy << std::endl;
+  }
+#endif
 }
 
 
diff --git a/Src/DasherCore/DasherViewSquare.inl b/Src/DasherCore/DasherViewSquare.inl
index 446ffd4..b6b5b0f 100644
--- a/Src/DasherCore/DasherViewSquare.inl
+++ b/Src/DasherCore/DasherViewSquare.inl
@@ -62,7 +62,7 @@ namespace Dasher {
       dx *= m_dXmpc;
     else
       dx = m_dXmpc * (m_dXmpa * log((dx + m_dXmpa - m_dXmpb) / m_dXmpa) + m_dXmpb);
-    return myint(dx * GetLongParameter(LP_MAX_Y));
+    return myint(ceil(dx * GetLongParameter(LP_MAX_Y)));
   }
 
   inline myint CDasherViewSquare::ymap(myint y) const {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]