OSSIM - Open Source Software Image Map
Version 1.9.0 (20180803)
src
base
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 $
9
#include <
ossim/base/ossim2dLinearRegression.h
>
10
11
ossim2dLinearRegression::ossim2dLinearRegression
()
12
{
13
clear
();
14
}
15
16
void
ossim2dLinearRegression::solve
()
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
}
ossim2dLinearRegression::theSlope
double theSlope
Definition:
ossim2dLinearRegression.h:73
ossim2dLinearRegression::theSolvedFlag
bool theSolvedFlag
Definition:
ossim2dLinearRegression.h:74
ossim2dLinearRegression::theSumY
double theSumY
Definition:
ossim2dLinearRegression.h:67
ossim2dLinearRegression::theSumXX
double theSumXX
Definition:
ossim2dLinearRegression.h:68
ossim2dLinearRegression::theNumberOfPoints
ossim_uint32 theNumberOfPoints
Definition:
ossim2dLinearRegression.h:65
ossim2dLinearRegression::clear
void clear()
Definition:
ossim2dLinearRegression.h:44
ossim2dLinearRegression::theIntercept
double theIntercept
Definition:
ossim2dLinearRegression.h:72
FLT_EPSILON
#define FLT_EPSILON
Definition:
ossimConstants.h:438
ossim2dLinearRegression.h
ossim2dLinearRegression::ossim2dLinearRegression
ossim2dLinearRegression()
Definition:
ossim2dLinearRegression.cpp:11
ossim2dLinearRegression::solve
void solve()
Definition:
ossim2dLinearRegression.cpp:16
ossim2dLinearRegression::theSumXY
double theSumXY
Definition:
ossim2dLinearRegression.h:70
ossim2dLinearRegression::theSumX
double theSumX
Definition:
ossim2dLinearRegression.h:66
Generated on Fri Aug 3 2018 08:46:45 for OSSIM - Open Source Software Image Map by
1.8.14