Go to the documentation of this file.00001
00002 #ifndef vdgl_ortho_regress_h_
00003 #define vdgl_ortho_regress_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 class vdgl_ortho_regress
00022 {
00023 public:
00024 unsigned S1;
00025 double Sx, Sy;
00026 double Sxx, Sxy, Syy;
00027
00028 void reset() {
00029 S1 = 0;
00030 Sx = Sy = 0;
00031 Sxx = Sxy = Syy =0;
00032 }
00033
00034 vdgl_ortho_regress() { reset(); }
00035
00036 ~vdgl_ortho_regress() { }
00037
00038 void add_point(double x, double y) {
00039 ++S1;
00040 Sx += x; Sy += y;
00041 Sxx += x*x; Sxy += x*y; Syy += y*y;
00042 }
00043 void add_points(double const *, double const *, unsigned);
00044 void add_points(float const *, float const *, unsigned);
00045
00046 void remove_point(double x, double y) {
00047 --S1;
00048 Sx -= x; Sy -= y;
00049 Sxx -= x*x; Sxy -= x*y; Syy -= y*y;
00050 }
00051 void remove_points(double const *, double const *, unsigned);
00052 void remove_points(float const *, float const *, unsigned);
00053
00054 double cost(double a, double b, double c) const;
00055 double rms_cost(double a, double b, double c) const;
00056
00057
00058 bool fit(double *a, double *b, double *c) const
00059 { return fit(*a, *b, *c); }
00060 bool fit_constrained(double x, double y, double *a, double *b, double *c) const
00061 { return fit_constrained(x, y, *a, *b, *c); }
00062
00063 protected:
00064
00065 bool fit(double &a, double &b, double &c) const;
00066 bool fit_constrained(double x, double y, double &a, double &b, double &c) const;
00067 };
00068
00069 #endif // vdgl_ortho_regress_h_