52 #ifndef __PCL_LinearFit_h
53 #define __PCL_LinearFit_h
67 class PCL_CLASS StatusMonitor;
130 return 1 + a == 1 && 1 + b == 1;
139 return 1 + a == 1 && 1 - b == 0;
145 double operator ()(
double x )
const
169 template <
typename T>
172 b = double( y2 - y1 )/double( x2 - x1 );
173 a = (y2 - b*x2 + y1 - b*x1)/2;
198 template <
typename T>
202 throw Error(
"LinearFit::LinearFit(): Less than two data points specified." );
206 b = double( y[1] - y[0] )/double( x[1] - x[0] );
207 a = (y[1] - b*x[1] + y[0] - b*x[0])/2;
211 Fit( a, b, adev, x, y, n, status );
242 throw Error(
"LinearFit::LinearFit(): Less than two data points specified." );
246 b = double( y[1] - y[0] )/double( x[1] - x[0] );
247 a = (y[1] - b*x[1] + y[0] - b*x[0])/2;
251 Fit( a, b, adev, x.Begin(), y.Begin(), n, status );
256 static void Fit(
double& a,
double& b,
double& adev,
258 static void Fit(
double& a,
double& b,
double& adev,
A simple exception with an associated error message.
Robust straight line fitting by minimization of mean absolute deviation.
LinearFit(T x1, T y1, T x2, T y2)
LinearFit(const LinearFit &)=default
LinearFit(const C &x, const C &y, StatusMonitor *status=nullptr)
LinearFit(const T *x, const T *y, size_type n, StatusMonitor *status=nullptr)
An asynchronous status monitoring system.
bool IsFinite(float x) noexcept
constexpr const T & Min(const T &a, const T &b) noexcept