Go to the documentation of this file.00001
00002 #ifndef osl_ortho_regress_h_
00003 #define osl_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
00022
00023
00024
00025 class osl_ortho_regress
00026 {
00027 public:
00028 unsigned S1;
00029 double Sx, Sy;
00030 double Sxx, Sxy, Syy;
00031
00032 void reset() {
00033 S1 = 0;
00034 Sx = Sy = 0;
00035 Sxx = Sxy = Syy =0;
00036 }
00037
00038 osl_ortho_regress() { reset(); }
00039
00040 ~osl_ortho_regress() { }
00041
00042 void add_point(double x, double y) {
00043 ++S1;
00044 Sx += x; Sy += y;
00045 Sxx += x*x; Sxy += x*y; Syy += y*y;
00046 }
00047 void add_points(double const *, double const *, unsigned);
00048 void add_points(float const *, float const *, unsigned);
00049
00050 void remove_point(double x, double y) {
00051 --S1;
00052 Sx -= x; Sy -= y;
00053 Sxx -= x*x; Sxy -= x*y; Syy -= y*y;
00054 }
00055 void remove_points(double const *, double const *, unsigned);
00056 void remove_points(float const *, float const *, unsigned);
00057
00058 double cost(double a, double b, double c) const;
00059 double rms_cost(double a, double b, double c) const;
00060
00061
00062 bool fit(double *a, double *b, double *c) const
00063 { return fit(*a, *b, *c); }
00064 bool fit_constrained(double x, double y, double *a, double *b, double *c) const
00065 { return fit_constrained(x, y, *a, *b, *c); }
00066
00067 protected:
00068
00069 bool fit(double &a, double &b, double &c) const;
00070 bool fit_constrained(double x, double y, double &a, double &b, double &c) const;
00071 };
00072
00073 #endif // osl_ortho_regress_h_