OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossim2dLinearRegression.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Garrett Potts (gpotts@imagelinks)
6 //
7 //*************************************************************************
8 // $Id: ossim2dLinearRegression.cpp 9966 2006-11-29 02:01:07Z gpotts $
10 
12 {
13  clear();
14 }
15 
17 {
18 
19 // theSumX = 0.0;
20 // theSumXX = 0.0;
21 // theSumY = 0.0;
22 // theSumYY = 0.0;
23 // theIntercept = 0.0;
24 // theSlope = 0.0;
25 // theSumXY = 0.0;
26 // ossim_uint32 idx = 0;
27 // for(idx = 0; idx < thePoints.size(); ++idx)
28 // {
29 // theSumX += thePoints[idx].x;
30 // theSumY += thePoints[idx].y;
31 // theSumXX += thePoints[idx].x*thePoints[idx].x;
32 // theSumYY += thePoints[idx].y*thePoints[idx].y;
33 // theSumXY += thePoints[idx].x*thePoints[idx].y;
34 
35 // }
36 
37  double numberOfPoints = (double)theNumberOfPoints;
38 
39  if(numberOfPoints < 1)
40  {
41  theSlope = 0.0;
42  theIntercept = 0.0;
43  return;
44  }
45  double Sxx = theSumXX - ((theSumX*theSumX)/numberOfPoints);
46  double Sxy = theSumXY - ((theSumX*theSumY)/numberOfPoints);
47 
48  if(fabs(Sxx) < FLT_EPSILON)
49  {
50  theSlope = 0.0;
51  theIntercept = 0.0;
52  return;
53  }
54 
55  theSlope = Sxy/Sxx;
56  theIntercept = (theSumY - theSlope*theSumX)/numberOfPoints;
57 
58  theSolvedFlag = true;
59 }
#define FLT_EPSILON