ccstruct/mod128.cpp

Go to the documentation of this file.
00001 
00020 #include          "mfcpch.h"     //precompiled headers
00021 #include          "mod128.h"
00022 
00024 static INT16 idirtab[] = {
00025   1000, 0, 998, 49, 995, 98, 989, 146,
00026   980, 195, 970, 242, 956, 290, 941, 336,
00027   923, 382, 903, 427, 881, 471, 857, 514,
00028   831, 555, 803, 595, 773, 634, 740, 671,
00029   707, 707, 671, 740, 634, 773, 595, 803,
00030   555, 831, 514, 857, 471, 881, 427, 903,
00031   382, 923, 336, 941, 290, 956, 242, 970,
00032   195, 980, 146, 989, 98, 995, 49, 998,
00033   0, 1000, -49, 998, -98, 995, -146, 989,
00034   -195, 980, -242, 970, -290, 956, -336, 941,
00035   -382, 923, -427, 903, -471, 881, -514, 857,
00036   -555, 831, -595, 803, -634, 773, -671, 740,
00037   -707, 707, -740, 671, -773, 634, -803, 595,
00038   -831, 555, -857, 514, -881, 471, -903, 427,
00039   -923, 382, -941, 336, -956, 290, -970, 242,
00040   -980, 195, -989, 146, -995, 98, -998, 49,
00041   -1000, 0, -998, -49, -995, -98, -989, -146,
00042   -980, -195, -970, -242, -956, -290, -941, -336,
00043   -923, -382, -903, -427, -881, -471, -857, -514,
00044   -831, -555, -803, -595, -773, -634, -740, -671,
00045   -707, -707, -671, -740, -634, -773, -595, -803,
00046   -555, -831, -514, -857, -471, -881, -427, -903,
00047   -382, -923, -336, -941, -290, -956, -242, -970,
00048   -195, -980, -146, -989, -98, -995, -49, -998,
00049   0, -1000, 49, -998, 98, -995, 146, -989,
00050   195, -980, 242, -970, 290, -956, 336, -941,
00051   382, -923, 427, -903, 471, -881, 514, -857,
00052   555, -831, 595, -803, 634, -773, 671, -740,
00053   707, -707, 740, -671, 773, -634, 803, -595,
00054   831, -555, 857, -514, 881, -471, 903, -427,
00055   923, -382, 941, -336, 956, -290, 970, -242,
00056   980, -195, 989, -146, 995, -98, 998, -49
00057 };
00058 
00059 static ICOORD *dirtab = (ICOORD *) idirtab;
00060 
00064 DIR128::DIR128(                 //from fcoord
00065                const FCOORD fc  //vector to quantize
00066               ) {
00067   int high, low, current;        //binary search
00068 
00069   low = 0;
00070   if (fc.y () == 0) {
00071     if (fc.x () >= 0)
00072       dir = 0;
00073     else
00074       dir = MODULUS / 2;
00075     return;
00076   }
00077   high = MODULUS;
00078   do {
00079     current = (high + low) / 2;
00080     if (dirtab[current] * fc >= 0)
00081       low = current;
00082     else
00083       high = current;
00084   }
00085   while (high - low > 1);
00086   dir = low;
00087 }
00088 
00089 
00093 ICOORD DIR128::vector() const {  //convert to vector
00094   return dirtab[dir];            //easy really
00095 }

Generated on Wed Feb 28 19:49:08 2007 for Tesseract by  doxygen 1.5.1