gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz ./Makefile gfx/libcoords/Coords.cxx gfx/lib...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz ./Makefile gfx/libcoords/Coords.cxx gfx/lib...
Date: Tue, 01 Oct 2002 06:14:47 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/10/01 06:14:47

Modified files:
        .              : Makefile 
        gfx/libcoords  : Coords.cxx 
        gfx/libfisheye : Fisheye.hxx 
        test           : testutil.py 
        test/gzz/gfx/gl: glvobcoorder.test 

Log message:
        Debugging the problem

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Makefile.diff?tr1=1.174&tr2=1.175&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.cxx.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libfisheye/Fisheye.hxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/testutil.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/gfx/gl/glvobcoorder.test.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: gzz/Makefile
diff -c gzz/Makefile:1.174 gzz/Makefile:1.175
*** gzz/Makefile:1.174  Tue Oct  1 02:42:55 2002
--- gzz/Makefile        Tue Oct  1 06:14:47 2002
***************
*** 373,379 ****
  batchtest:
        $(GLLIB) $(JYTHON) test/test.py
  runtest:  # Use: make runtest TEST=gzz/vob/vobmatcher, to run a single test.
!       $(GLLIB) $(JYTHON) test/testutil.py test/$(TEST).test
  run:
        $(JYTHON) Gzz.py $(DBG) -Dgzzclient=awt $(Z)
  rungl:
--- 373,379 ----
  batchtest:
        $(GLLIB) $(JYTHON) test/test.py
  runtest:  # Use: make runtest TEST=gzz/vob/vobmatcher, to run a single test.
!       $(GLLIB) $(JYTHON) test/testutil.py $(DBG) test/$(TEST).test
  run:
        $(JYTHON) Gzz.py $(DBG) -Dgzzclient=awt $(Z)
  rungl:
Index: gzz/gfx/libcoords/Coords.cxx
diff -c gzz/gfx/libcoords/Coords.cxx:1.22 gzz/gfx/libcoords/Coords.cxx:1.23
*** gzz/gfx/libcoords/Coords.cxx:1.22   Tue Oct  1 04:12:06 2002
--- gzz/gfx/libcoords/Coords.cxx        Tue Oct  1 06:14:47 2002
***************
*** 255,261 ****
       */
      class ScaleXYZCoords {
        ZVec vec; 
-       friend class DistortCoords;
      public:
        enum { NParams = 3 };
        template<class Ptr> void setParams(Ptr p) {
--- 255,260 ----
***************
*** 289,306 ****
        }
      } ;
  
! 
!     /** Distorted coordinate system.
       * Parameter layout: x, y (of center), log(mag), log(min), w, h.
       * W and h give the width and height in the inside coordinate system
       * of the zoomed area.
       */
!     class DistortCoords {
        float x, y;
        float w, h;
        float mmin;
        float mmax;
!       Fisheye::vector_mag_isotropic<Fisheye::scalar_mag_atan> distort;
      public:
        enum { NParams = 6 };
        template<class Ptr> void setParams(Ptr p) {
--- 288,305 ----
        }
      } ;
  
!     /** Isotropically distorted coordinate system.
       * Parameter layout: x, y (of center), log(mag), log(min), w, h.
       * W and h give the width and height in the inside coordinate system
       * of the zoomed area.
       */
!     template<class F> class DistortCoords {
!       friend class DistortCoords<typename F::InverseType>;
        float x, y;
        float w, h;
        float mmin;
        float mmax;
!       F distort;
      public:
        enum { NParams = 6 };
        template<class Ptr> void setParams(Ptr p) {
***************
*** 310,316 ****
            mmin = exp(p[3]);
            w = p[4];
            h = p[5];
!           distort.f = Fisheye::scalar_mag_atan(mmax / mmin);
        }
        void tr(const ZPt &from, ZPt &to) const {
            ZPt p = ZPt((from.x-x) / w, (from.y-y)/ h, from.z);
--- 309,315 ----
            mmin = exp(p[3]);
            w = p[4];
            h = p[5];
!           distort.setMag(mmax / mmin);
        }
        void tr(const ZPt &from, ZPt &to) const {
            ZPt p = ZPt((from.x-x) / w, (from.y-y)/ h, from.z);
***************
*** 320,329 ****
            to.y *= mmin;
            to.x += x; to.y += y;
        }
!       typedef ScaleXYZCoords InverseType; // XXX !!!
!       ScaleXYZCoords inverseTransform() {
!           ScaleXYZCoords inv;
!           inv.vec = ZVec(1,1,1); // XXX!
            return inv;
        }
        bool canPerformGL() { return false; }
--- 319,334 ----
            to.y *= mmin;
            to.x += x; to.y += y;
        }
!       typedef DistortCoords<typename F::InverseType>  InverseType; // XXX !!!
!       InverseType inverseTransform() {
!           InverseType inv;
!           inv.x = x;
!           inv.y = y;
!           inv.w = w;
!           inv.h = h;
!           inv.mmin = 1/mmin;
!           inv.mmax = mmax;
!           inv.distort.setMag(mmax/mmin);
            return inv;
        }
        bool canPerformGL() { return false; }
***************
*** 356,362 ****
        0, 
        new Factory<AffineXYCoords>(),
        new Factory<RotateXYCoords>(),
!       new Factory<DistortCoords>(),
        new Factory<RotateXYZCoords>(),
        new Factory<ScaleXYZCoords>(),
        0
--- 361,367 ----
        0, 
        new Factory<AffineXYCoords>(),
        new Factory<RotateXYCoords>(),
!       new 
Factory<DistortCoords<Fisheye::vector_mag_isotropic<Fisheye::scalar_mag_atan> > 
>(),
        new Factory<RotateXYZCoords>(),
        new Factory<ScaleXYZCoords>(),
        0
Index: gzz/gfx/libfisheye/Fisheye.hxx
diff -c gzz/gfx/libfisheye/Fisheye.hxx:1.3 gzz/gfx/libfisheye/Fisheye.hxx:1.4
*** gzz/gfx/libfisheye/Fisheye.hxx:1.3  Mon Sep 30 04:15:42 2002
--- gzz/gfx/libfisheye/Fisheye.hxx      Tue Oct  1 06:14:47 2002
***************
*** 1,6 ****
--- 1,8 ----
  #include "libutil/Vec23.hxx"
+ #include "libutil/Debug.hxx"
  
  namespace Fisheye {
+     DBGVAR(dbg, "Fisheye.general");
  
      using namespace Vec23;
  
***************
*** 37,52 ****
--- 39,98 ----
            }
            return 1;
        }
+       float func(float r) const {
+           return 1 + z * atan(r) / r;
+       }
+       float inverse(float r2) const {
+           if(z <= 0) return 1; // Fail gracefully
+           if (r2 > 0) {
+               float r_orig = sqrt(r2);
+               float ylow = r_orig;
+               float yhigh = r_orig + z * M_PI / 2;
+               // Then, loop a little bit // XXX Improve
+               for(int i=0; i<15; i++) {
+                   float y = 0.5*(ylow+yhigh);
+                   float c = y * func(y);
+                   if(c < r_orig) {
+                       ylow = y;
+                   } else {
+                       yhigh = y;
+                   }
+                   DBG(dbg) << 
+                           "r_orig: " << r_orig << 
+                           "ylow: " << ylow << 
+                           "yhigh: " << yhigh << 
+                           "c: " << c << "\n";
+               }
+               return 0.5*(ylow+yhigh) / r_orig;
+           }
+           return 1;
+       }
      };
  
+     template<class F> struct inverse_vector_mag_isotropic ;
  
      template<class F> struct vector_mag_isotropic {
        vector_mag_isotropic() { }
        vector_mag_isotropic(F &f) : f(f) { }
+       void setMag(float mag) { f = F(mag); }
        F f;
+       typedef inverse_vector_mag_isotropic<F> InverseType;
        ZPt operator() (const ZPt &p) const {
            float r2 = p.x * p.x + p.y * p.y;
            float m = f(r2);
+           return ZPt(m * p.x, m * p.y, p.z);
+       }
+     };
+ 
+     template<class F> struct inverse_vector_mag_isotropic {
+       inverse_vector_mag_isotropic() { }
+       inverse_vector_mag_isotropic(F &f) : f(f) { }
+       void setMag(float mag) { f = F(mag); }
+       F f;
+       typedef vector_mag_isotropic<F> InverseType ;
+       ZPt operator() (const ZPt &p) const {
+           float r2 = p.x * p.x + p.y * p.y;
+           float m = f.inverse(r2);
            return ZPt(m * p.x, m * p.y, p.z);
        }
      };
Index: gzz/test/gzz/gfx/gl/glvobcoorder.test
diff -c gzz/test/gzz/gfx/gl/glvobcoorder.test:1.5 
gzz/test/gzz/gfx/gl/glvobcoorder.test:1.6
*** gzz/test/gzz/gfx/gl/glvobcoorder.test:1.5   Tue Oct  1 04:17:06 2002
--- gzz/test/gzz/gfx/gl/glvobcoorder.test       Tue Oct  1 06:14:47 2002
***************
*** 5,15 ****
  
  GL.loadLib()
  
! def checkTrans(c, cs, srclist, dstlist):
      src = array(srclist, 'f')
      dst = zeros(len(src), 'f')
      c.transformPoints3(cs, src, dst)
!     failUnlessEqual([x for x in dst], dstlist)
  
  
  def testTransform():
--- 5,16 ----
  
  GL.loadLib()
  
! def checkTrans(c, cs, srclist, dstlist, delta=0):
      src = array(srclist, 'f')
      dst = zeros(len(src), 'f')
      c.transformPoints3(cs, src, dst)
!     for i in range(0, len(src)):
!       failIf(abs(dst[i]-dstlist[i]) > delta, str([srclist, dstlist, dst, i, 
dst[i], dstlist[i]]))
  
  
  def testTransform():
***************
*** 17,24 ****
--- 18,31 ----
  
      cs = c.coordsys(0, 5, 10, 15, 0, 0)
      checkTrans(c, cs, [0, 0, 0, 1, 1, 1], [10, 15, 5, 10, 15, 6])
+ 
+     cs = c.scaleXYZ(0, 2, 3, 4)
+     checkTrans(c, cs, [0, 0, 0, 1, 1, 1], [0, 0, 0, 2, 3, 4])
      
  
+     cs = c.distort(0, 0, 0, 0.1, 0.1, 20, 5)
+     checkTrans(c, cs, [0, 0, 0, 0.001, 0.001, 1], [0, 0, 0, 0.02, 0.02, 1], 
delta=0.00001)
+ 
  def checkInverse(c, cs):
      # unit cube
      src = array([
***************
*** 72,75 ****
--- 79,85 ----
      checkInverse(c, cs_ortho4)
      checkInverse(c, cs_ortho5)
  
+     cs_dist = c.distort(0, 0, 0, 0.5, 0.1, 20, 5)
+ 
+     checkInverse(c, cs_dist)
  
Index: gzz/test/testutil.py
diff -c gzz/test/testutil.py:1.11 gzz/test/testutil.py:1.12
*** gzz/test/testutil.py:1.11   Mon Sep 30 18:20:28 2002
--- gzz/test/testutil.py        Tue Oct  1 06:14:47 2002
***************
*** 117,125 ****
  
  
  if __name__ == '__main__':
-     import sys
      test = ['test/']
      if len(sys.argv) > 1:
!       test = sys.argv[1:]
      unittest.TextTestRunner(verbosity=2).run(suite(test))
  
--- 117,136 ----
  
  
  if __name__ == '__main__':
      test = ['test/']
+     import sys
      if len(sys.argv) > 1:
!       sys.path.insert(0, ".")
!       import getopt
!       import gzz.util.dbg
!       opts, args = getopt.getopt(sys.argv[1:], 
!               gzz.util.dbg.short, 
!               gzz.util.dbg.long)
!       for o,a in opts:
!           print "Opt: ",o,a
!           if o in gzz.util.dbg.all:
!               gzz.util.dbg.option(o,a)
! 
!       test = args
      unittest.TextTestRunner(verbosity=2).run(suite(test))
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]