ccstruct/linlsq.h

Go to the documentation of this file.
00001 
00020 #ifndef           LINLSQ_H
00021 #define           LINLSQ_H
00022 
00023 #include          "points.h"
00024 #include          "mod128.h"
00025 #include          "varable.h"
00026 
00035 class LLSQ
00036 {
00037   friend class PDLSQ;            //pos & direction
00038 
00039   public:
00040     LLSQ() {  //constructor
00041       clear();  //set to zeros
00042     }
00043     void clear();  //initialize
00044 
00045     void add(           //add element
00046              double x,  //coords to add
00047              double y);
00048     void remove(           //delete element
00049                 double x,  //coords to delete
00050                 double y);
00051     INT32 count() {  //no of elements
00052       return n;
00053     }
00054 
00055     double m();  //get gradient
00056     double c(            //get constant
00057              double m);  //gradient
00058     double rms(            //get error
00059                double m,   //gradient
00060                double c);  //constant
00061     double spearman();  //get error
00062 
00063   private:
00064     INT32 n;                     //no of elements
00065     double sigx;                 //sum of x
00066     double sigy;                 //sum of y
00067     double sigxx;                //sum x squared
00068     double sigxy;                //sum of xy
00069     double sigyy;                //sum y squared
00070 };
00071 
00080 class PDLSQ
00081 {
00082   public:
00083     PDLSQ() {  //constructor
00084       clear();  //set to zeros
00085     }
00086     void clear() {  //initialize
00087       pos.clear ();              //clear both
00088       dir.clear ();
00089     }
00090 
00091     void add(                         //add element
00092              const ICOORD &addpos,    //position of pt
00093              const ICOORD &adddir) {  //dir of pt
00094       pos.add (addpos.x (), addpos.y ());
00095       dir.add (adddir.x (), adddir.y ());
00096     }
00097     void remove(                            //remove element
00098                 const ICOORD &removepos,    //position of pt
00099                 const ICOORD &removedir) {  //dir of pt
00100       pos.remove (removepos.x (), removepos.y ());
00101       dir.remove (removedir.x (), removedir.y ());
00102     }
00103     INT32 count() {  //no of elements
00104       return pos.count ();
00105     }
00106 
00107     float fit(                 //get fit parameters
00108               DIR128 &ang,     //output angle
00109               float &sin_ang,  //output components
00110               float &cos_ang,
00111               float &r);
00112 
00113   private:
00114     LLSQ pos;                    //position
00115     LLSQ dir;                    //directions
00116 };
00117 
00124 extern double_VAR_H (pdlsq_posdir_ratio, 0.4e-6, "Mult of dir to cf pos");
00127 #endif

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