OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Private Attributes | List of all members
ossimLeastSquaresPlane Class Reference


Provide 2D Least Squares Plane model fitting The math model is that of a plane of the form: More...

#include <ossimLeastSquaresPlane.h>

Public Member Functions

 ossimLeastSquaresPlane (const ossimLeastSquaresPlane &)
 
 ossimLeastSquaresPlane ()
 Instantiate as zero surface. More...
 
ossimLeastSquaresPlaneoperator= (const ossimLeastSquaresPlane &)
 
virtual ~ossimLeastSquaresPlane ()
 Free internal storage. More...
 
virtual void clear ()
 Will clear everything and set it up to for another solve. More...
 
virtual void addSample (double x, double y, double z_mea)
 add a single data sample. More...
 
virtual bool getLSParms (double &pa, double &pb, double &pc) const
 return LS solution parameters. More...
 
virtual void setLSParams (double pa, double pb, double pc)
 
virtual double lsFitValue (double xx, double yy) const
 interpolate LS-fit value at location (xx,yy) - returns z(xx,yy). More...
 
bool solveLS ()
 compute least squares parameter solution - true if succesfull. More...
 

Private Attributes

double m_a
 linear-X term. More...
 
double m_b
 linear-Y term. More...
 
double m_c
 constant term. More...
 
NEWMAT::Matrix * AtA
 Normal system coefficient matrix. More...
 
NEWMAT::Matrix * Atb
 Normal system RHS vector. More...
 
ossim_uint32 m_numSamples
 

Detailed Description


Provide 2D Least Squares Plane model fitting The math model is that of a plane of the form:

z(x,y) = ax + b*y + c

The getLSParms() method returns parameter values which are the least squares solution associated with the samples added via addSample(). Note that it is necessary to add at least three sample to obtain a solution.

Definition at line 27 of file ossimLeastSquaresPlane.h.

Constructor & Destructor Documentation

◆ ossimLeastSquaresPlane() [1/2]

ossimLeastSquaresPlane::ossimLeastSquaresPlane ( const ossimLeastSquaresPlane rhs)

Definition at line 35 of file ossimLeastSquaresPlane.cpp.

References AtA, Atb, m_a, m_b, and m_c.

36 {
37  // allocate normal system accumulation matrices
38  AtA = new NEWMAT::Matrix(3,3);
39  Atb = new NEWMAT::Matrix(3,1);
40 
41  m_a = rhs.m_a;
42  m_b = rhs.m_b;
43  m_c = rhs.m_c;
44 
45  *AtA = *rhs.AtA;
46  *Atb = *rhs.Atb;
47 }
double m_b
linear-Y term.
double m_c
constant term.
double m_a
linear-X term.
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
NEWMAT::Matrix * Atb
Normal system RHS vector.

◆ ossimLeastSquaresPlane() [2/2]

ossimLeastSquaresPlane::ossimLeastSquaresPlane ( )

Instantiate as zero surface.

Definition at line 16 of file ossimLeastSquaresPlane.cpp.

References AtA, and Atb.

17 : m_a(0.0),
18  m_b(0.0),
19  m_c(0.0),
20  AtA(NULL),
21  Atb(NULL),
22  m_numSamples(0)
23 {
24  // allocate normal system accumulation matrices
25  AtA = new NEWMAT::Matrix(3,3);
26  Atb = new NEWMAT::Matrix(3,1);
27 
28  // ensure initilization to zero
29  *AtA = 0.0;
30  *Atb = 0.0;
31 
32  return;
33 }
double m_b
linear-Y term.
double m_c
constant term.
double m_a
linear-X term.
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
NEWMAT::Matrix * Atb
Normal system RHS vector.

◆ ~ossimLeastSquaresPlane()

ossimLeastSquaresPlane::~ossimLeastSquaresPlane ( )
virtual

Free internal storage.

Definition at line 49 of file ossimLeastSquaresPlane.cpp.

References AtA, and Atb.

50 {
51  if(AtA)
52  {
53  delete AtA;
54  AtA = NULL;
55  }
56  if(Atb)
57  {
58  delete Atb;
59  Atb = NULL;
60  }
61 }
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
NEWMAT::Matrix * Atb
Normal system RHS vector.

Member Function Documentation

◆ addSample()

void ossimLeastSquaresPlane::addSample ( double  x,
double  y,
double  z_mea 
)
virtual

add a single data sample.

Parameters
xcoordinate of sample location.
ycoordinate of sample location.
zmeasample value measured at (x,y)

Definition at line 83 of file ossimLeastSquaresPlane.cpp.

References AtA, Atb, and m_numSamples.

84 {
85  // form normal system layer
86  NEWMAT::Matrix AtA_layer(3,1);
87  AtA_layer(1,1) = xx;
88  AtA_layer(2,1) = yy;
89  AtA_layer(3,1) = 1.0;
90 
91  // accumulate layer into normal system
92  *AtA += AtA_layer * AtA_layer.t();
93  *Atb += AtA_layer * zmea;
94 
95  ++m_numSamples;
96 }
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
NEWMAT::Matrix * Atb
Normal system RHS vector.

◆ clear()

void ossimLeastSquaresPlane::clear ( )
virtual

Will clear everything and set it up to for another solve.

Just add points and call the solve method.

Definition at line 74 of file ossimLeastSquaresPlane.cpp.

References AtA, Atb, m_a, m_b, and m_c.

75 {
76  *AtA = 0.0;
77  *Atb = 0.0;
78  m_a = 0.0;
79  m_b = 0.0;
80  m_c = 0.0;
81 }
double m_b
linear-Y term.
double m_c
constant term.
double m_a
linear-X term.
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
NEWMAT::Matrix * Atb
Normal system RHS vector.

◆ getLSParms()

bool ossimLeastSquaresPlane::getLSParms ( double &  pa,
double &  pb,
double &  pc 
) const
virtual

return LS solution parameters.

Parameters
paset to x coefficient.
pbset to y coefficient
pcset to constant term

Definition at line 112 of file ossimLeastSquaresPlane.cpp.

References m_a, m_b, and m_c.

113 {
114  pa = m_a;
115  pb = m_b;
116  pc = m_c;
117 
118  return true;
119 }
double m_b
linear-Y term.
double m_c
constant term.
double m_a
linear-X term.

◆ lsFitValue()

virtual double ossimLeastSquaresPlane::lsFitValue ( double  xx,
double  yy 
) const
inlinevirtual

interpolate LS-fit value at location (xx,yy) - returns z(xx,yy).

Parameters
xx"x" coordinate at which to interpolate.
yy"y" "y" coordinate at which to interpolate.

Definition at line 83 of file ossimLeastSquaresPlane.h.

83 { return (m_a*xx + m_b*yy + m_c); }
double m_b
linear-Y term.
double m_c
constant term.
double m_a
linear-X term.

◆ operator=()

ossimLeastSquaresPlane & ossimLeastSquaresPlane::operator= ( const ossimLeastSquaresPlane rhs)

Definition at line 62 of file ossimLeastSquaresPlane.cpp.

References AtA, Atb, m_a, m_b, and m_c.

63 {
64  m_a = rhs.m_a;
65  m_b = rhs.m_b;
66  m_c = rhs.m_c;
67 
68  *AtA = *rhs.AtA;
69  *Atb = *rhs.Atb;
70 
71  return *this;
72 }
double m_b
linear-Y term.
double m_c
constant term.
double m_a
linear-X term.
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
NEWMAT::Matrix * Atb
Normal system RHS vector.

◆ setLSParams()

void ossimLeastSquaresPlane::setLSParams ( double  pa,
double  pb,
double  pc 
)
virtual
Parameters
paset to x coefficient.
pbset to y coefficient
pcset to constant term

Definition at line 121 of file ossimLeastSquaresPlane.cpp.

References m_a, m_b, and m_c.

122 {
123  m_a = pa;
124  m_b = pb;
125  m_c = pc;
126 }
double m_b
linear-Y term.
double m_c
constant term.
double m_a
linear-X term.

◆ solveLS()

bool ossimLeastSquaresPlane::solveLS ( )

compute least squares parameter solution - true if succesfull.

Definition at line 98 of file ossimLeastSquaresPlane.cpp.

References AtA, m_a, m_b, m_c, and m_numSamples.

99 {
100  if (m_numSamples < 3)
101  return false;
102 
103  NEWMAT::Matrix Soln(3,1);
104  Soln = AtA->i() * (*Atb);
105  m_a = Soln(1,1);
106  m_b = Soln(2,1);
107  m_c = Soln(3,1);
108 
109  return true;
110 }
double m_b
linear-Y term.
double m_c
constant term.
double m_a
linear-X term.
NEWMAT::Matrix * AtA
Normal system coefficient matrix.

Member Data Documentation

◆ AtA

NEWMAT::Matrix* ossimLeastSquaresPlane::AtA
private

Normal system coefficient matrix.

Definition at line 110 of file ossimLeastSquaresPlane.h.

Referenced by addSample(), clear(), operator=(), ossimLeastSquaresPlane(), solveLS(), and ~ossimLeastSquaresPlane().

◆ Atb

NEWMAT::Matrix* ossimLeastSquaresPlane::Atb
private

Normal system RHS vector.

Definition at line 115 of file ossimLeastSquaresPlane.h.

Referenced by addSample(), clear(), operator=(), ossimLeastSquaresPlane(), and ~ossimLeastSquaresPlane().

◆ m_a

double ossimLeastSquaresPlane::m_a
private

linear-X term.

Definition at line 95 of file ossimLeastSquaresPlane.h.

Referenced by clear(), getLSParms(), operator=(), ossimLeastSquaresPlane(), setLSParams(), and solveLS().

◆ m_b

double ossimLeastSquaresPlane::m_b
private

linear-Y term.

Definition at line 100 of file ossimLeastSquaresPlane.h.

Referenced by clear(), getLSParms(), operator=(), ossimLeastSquaresPlane(), setLSParams(), and solveLS().

◆ m_c

double ossimLeastSquaresPlane::m_c
private

constant term.

Definition at line 105 of file ossimLeastSquaresPlane.h.

Referenced by clear(), getLSParms(), operator=(), ossimLeastSquaresPlane(), setLSParams(), and solveLS().

◆ m_numSamples

ossim_uint32 ossimLeastSquaresPlane::m_numSamples
private

Definition at line 117 of file ossimLeastSquaresPlane.h.

Referenced by addSample(), and solveLS().


The documentation for this class was generated from the following files: