proj home

Files   Classes   Functions   Hierarchy  

leastsqrs Class Reference

Fit connected straight lines in 2D minimizing their length. More...

#include <leastsqrs.h>

Collaboration diagram for leastsqrs:

List of all members.

Public Member Functions

 leastsqrs (vector< pt2 > const &pts_, double const alpha_=1.0, double const beta_=1.0)
 ~leastsqrs ()
void operator() (double &fval)

Public Attributes

double alpha
 The weight of the change in y.
double beta
 The weight of the line length.
double * xi
 The varying y coordinate state.


Detailed Description

Fit connected straight lines in 2D minimizing their length.

Minimize the y coordinate of each point. alpha * distance(pts[i].y-x[i])

Minimize the straight line segment lengths. beta * dist(pts[i+1],pts[i])

Definition at line 19 of file leastsqrs.h.


Constructor & Destructor Documentation

leastsqrs::leastsqrs ( vector< pt2 > const &  pts_,
double const   alpha_ = 1.0,
double const   beta_ = 1.0 
)

Definition at line 4 of file leastsqrs.cpp.

References pts.

00009   : pts(pts_), alpha(alpha_), beta(beta_)
00010 {
00011   size = pts.size();
00012 
00013   xi = new double[size];
00014 }

leastsqrs::~leastsqrs (  ) 

Definition at line 37 of file leastsqrs.cpp.

References xi.

00038 {
00039   delete[] xi;
00040   xi=0;
00041 }


Member Function Documentation

void leastsqrs::operator() ( double &  fval  ) 

Definition at line 17 of file leastsqrs.cpp.

References pts.

00020 {
00021   fval=0.0;
00022   double z;
00023   for (uint i=0; i<size; ++i)
00024   {
00025     z = pts[i].y-xi[i];
00026     fval += alpha*z*z;
00027   }
00028   for (uint i=0; i<size-1; ++i)
00029   {
00030     z = (pts[i].x-pts[i+1].x);  //can remove
00031     fval += beta*z*z;
00032     z = xi[i+1]-xi[i];
00033     fval += beta*z*z;
00034   }
00035 }


Member Data Documentation

The weight of the change in y.

Definition at line 27 of file leastsqrs.h.

The weight of the line length.

Definition at line 29 of file leastsqrs.h.

double* leastsqrs::xi

The varying y coordinate state.

Definition at line 31 of file leastsqrs.h.

Referenced by ~leastsqrs().


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

Generated on Fri Mar 4 00:50:04 2011 for Chelton Evans Source by  doxygen 1.5.8