Public Member Functions | List of all members
mirtk::Polynomial Class Reference

#include <Polynomial.h>

Inheritance diagram for mirtk::Polynomial:
Inheritance graph
Collaboration diagram for mirtk::Polynomial:
Collaboration graph

Public Member Functions

void Coefficient (int i, double c)
 
double Coefficient (int i) const
 
void Coefficients (const Vector &coeff)
 
Vector Evaluate (const Matrix &x) const
 
Vector Evaluate (const PointSet &x, bool twoD=false) const
 
Vector Evaluate (const Vector &x) const
 
double Evaluate (const Point &x, bool twoD=false) const
 
double Evaluate (double x, double y, double z) const
 
double Evaluate (double x, double y) const
 
double Evaluate (double x) const
 
Vector Evaluate1stOrderDerivative (int j, const Matrix &x) const
 
Vector Evaluate1stOrderDerivative (int j, const PointSet &x, bool twoD=false) const
 
Vector Evaluate1stOrderDerivative (int j, const Vector &x) const
 
double Evaluate1stOrderDerivative (int j, const Point &x, bool twoD=false) const
 
double Evaluate1stOrderDerivative (int j, double x) const
 
Vector Evaluate2ndOrderDerivative (int j1, int j2, const Matrix &x) const
 
Vector Evaluate2ndOrderDerivative (int j1, int j2, const PointSet &x, bool twoD=false) const
 
Vector Evaluate2ndOrderDerivative (int j1, int j2, const Vector &x) const
 
double Evaluate2ndOrderDerivative (int j1, int j2, const Point &x, bool twoD=false) const
 
double Evaluate2ndOrderDerivative (int j1, int j2, double x) const
 
double EvaluateGaussianCurvature (const Point &x) const
 
Vector3 EvaluateGradient (const Point &x) const
 
Matrix3x3 EvaluateHessian (const Point &x) const
 
double EvaluateMeanCurvature (const Point &x) const
 
double EvaluateTaubinDistance (const Point &x) const
 
int Exponent (int i, int j=0) const
 
double Fit (const Matrix &x, const Vector &y)
 
double Fit (const Matrix &x, const Vector &y, const Array< int > &subset)
 
double Fit (const Matrix &x, const Vector &y, const OrderedSet< int > &subset)
 
double Fit (const PointSet &x, const Vector &y, bool twoD=false)
 
double Fit (const Vector &x, const Vector &y)
 
double FitSurface (const PointSet &x)
 
double FitSurface (const PointSet &x, const Array< int > &subset)
 
double FitSurface (const PointSet &x, const OrderedSet< int > &subset)
 
double FitSurface (const PointSet &x, const PointSet &n, double c=1.0)
 
double FitSurface (const PointSet &x, const PointSet &n, const Array< int > &subset, double c=1.0)
 
double FitSurface (const PointSet &x, const PointSet &n, const OrderedSet< int > &subset, double c=1.0)
 
int Initialize (int p, int order=0)
 
bool IsConstant (int i) const
 
int NumberOfActiveTerms () const
 Number of active model terms/coefficients.
 
int NumberOfPassiveTerms () const
 Number of passive model terms/coefficients.
 
int NumberOfTerms () const
 Number of model terms/coefficients.
 
Polynomialoperator= (const Polynomial &)
 Assignment operator.
 
 Polynomial (int order=2)
 
 Polynomial (int p, int order, const Vector &coeff=Vector())
 
 Polynomial (const Polynomial &)
 Copy constructor.
 
ostream & Print (ostream &os, Indent=0) const
 Print polynomial model equation.
 
void Print (Indent=0) const
 Print polynomial model equation.
 
void SetCoefficientsToZero ()
 Set all model coefficients to zero.
 
void SetConstantCoefficient (double value, enum Status status=Passive)
 
enum Status Status (int i) const
 
void Status (int i, enum Status s)
 
virtual ~Polynomial ()
 Destructor.
 
- Public Member Functions inherited from mirtk::Object
virtual const char * NameOfClass () const =0
 Get name of class, which this object is an instance of.
 
virtual ParameterList Parameter () const
 Get parameter name/value pairs.
 
bool Parameter (const ParameterList &)
 Set parameters from name/value pairs.
 
virtual bool Set (const char *name, const char *value)
 
virtual ~Object ()
 Destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from mirtk::Object
static const char * NameOfType ()
 Get name of this class type.
 
- Protected Member Functions inherited from mirtk::Object
template<typename... Args>
void Throw (ErrorType err, const char *func, Args... args) const
 
- Static Protected Member Functions inherited from mirtk::Object
template<typename... Args>
static void ThrowStatic (ErrorType err, const char *cls, const char *func, Args... args)
 

Detailed Description

N-dimensional polynomial regression model.

This implementation is based on the polyfitn and polyvaln MATLAB functions written and distributed on MathCentral by John D'Errico.

See also
http://uk.mathworks.com/matlabcentral/fileexchange/34765-polyfitn

Definition at line 47 of file Polynomial.h.

Constructor & Destructor Documentation

§ Polynomial() [1/2]

mirtk::Polynomial::Polynomial ( int  order = 2)

Constructor

Parameters
[in]orderOrder of the polynomial, i.e., highest model term exponent.

§ Polynomial() [2/2]

mirtk::Polynomial::Polynomial ( int  p,
int  order,
const Vector coeff = Vector() 
)

Construct complete polynomial

Parameters
[in]pDimension of independent variable space.
[in]orderOrder of the polynomial, i.e., highest model term exponent.
[in]coeffCoefficients of each model term. If not specified, the coefficients are initialized to zero. Use Coefficients(const Vector &) in this case to set the coefficients of the model terms after model construction.

Member Function Documentation

§ Coefficient() [1/2]

void mirtk::Polynomial::Coefficient ( int  i,
double  c 
)
inline

Set coefficient of i-th term

Parameters
[in]iIndex of model term.
[in]cModel term coefficient.

Definition at line 587 of file Polynomial.h.

§ Coefficient() [2/2]

double mirtk::Polynomial::Coefficient ( int  i) const
inline

Get coefficient of i-th term

Parameters
[in]iIndex of model term.
Returns
Coefficient of i-th term.

Definition at line 594 of file Polynomial.h.

§ Coefficients()

void mirtk::Polynomial::Coefficients ( const Vector coeff)
inline

Set coefficients of polynomial model terms

Parameters
[in]coeffCoefficient vector of length NumberOfTerms().

Definition at line 580 of file Polynomial.h.

§ Evaluate() [1/7]

Vector mirtk::Polynomial::Evaluate ( const Matrix x) const

Evaluates polynomial for n p-dimensional data points

Parameters
[in]xMatrix of size (n x p), where n is the number of data points to evaluate, and p is the dimension of the independent variable space of the polynomial model.
Returns
Regressed value.

§ Evaluate() [2/7]

Vector mirtk::Polynomial::Evaluate ( const PointSet x,
bool  twoD = false 
) const
inline

Evaluates polynomial for n 2- or 3-dimensional data points

Parameters
[in]xData points. The dimension of the model must be 2 or 3.
[in]twoDWhether to ignore z coordinate.
Returns
Regressed value.

Definition at line 641 of file Polynomial.h.

§ Evaluate() [3/7]

Vector mirtk::Polynomial::Evaluate ( const Vector x) const
inline

Evaluates polynomial for n 1-dimensional data points

Parameters
[in]xValues of independent variable. The dimension of the model must be 1.
Returns
Regressed values.

Definition at line 649 of file Polynomial.h.

§ Evaluate() [4/7]

double mirtk::Polynomial::Evaluate ( const Point x,
bool  twoD = false 
) const
inline

Evaluates polynomial for one 3D point

Parameters
[in]xData point. The dimension of the model must be 2 or 3.
[in]twoDWhether to ignore z coordinate.
Returns
Regressed value.

Definition at line 656 of file Polynomial.h.

§ Evaluate() [5/7]

double mirtk::Polynomial::Evaluate ( double  x,
double  y,
double  z 
) const
inline

Evaluates polynomial for one 3D point

Parameters
[in]xFirst point coordinate.
[in]ySecond point coordinate.
[in]zThird point coordinate.
Returns
Regressed value.

Definition at line 668 of file Polynomial.h.

§ Evaluate() [6/7]

double mirtk::Polynomial::Evaluate ( double  x,
double  y 
) const
inline

Evaluates polynomial for one 2D point

Parameters
[in]xFirst point coordinate.
[in]ySecond point coordinate.
Returns
Regressed value.

Definition at line 679 of file Polynomial.h.

§ Evaluate() [7/7]

double mirtk::Polynomial::Evaluate ( double  x) const
inline

Evaluates polynomial for one independent variable value

Parameters
[in]xData point. The dimension of the model must be 1.
Returns
Regressed value.

Definition at line 689 of file Polynomial.h.

§ Evaluate1stOrderDerivative() [1/5]

Vector mirtk::Polynomial::Evaluate1stOrderDerivative ( int  j,
const Matrix x 
) const

Evaluate 1st order partial derivative of polynomial

Parameters
[in]jIndex of independent variable w.r.t. which the derivative is taken.
[in]xMatrix of size (n x p), where n is the number of data points to evaluate, and p is the dimension of the independent variable space of the polynomial model.
Returns
Values of 1st order derivative evaluated at given data points.

§ Evaluate1stOrderDerivative() [2/5]

Vector mirtk::Polynomial::Evaluate1stOrderDerivative ( int  j,
const PointSet x,
bool  twoD = false 
) const
inline

Evaluate 1st order partial derivative of polynomial

Parameters
[in]jIndex of independent variable w.r.t. which the derivative is taken.
[in]xData points. The dimension of the model must be 2 or 3.
[in]twoDWhether to ignore z coordinate.
Returns
Values of 1st order derivative evaluated at given data points.

Definition at line 702 of file Polynomial.h.

§ Evaluate1stOrderDerivative() [3/5]

Vector mirtk::Polynomial::Evaluate1stOrderDerivative ( int  j,
const Vector x 
) const
inline

Evaluate 1st order partial derivative of polynomial

Parameters
[in]jIndex of independent variable w.r.t. which the derivative is taken.
[in]xValues of independent variable. The dimension of the model must be 1.
Returns
Values of 1st order derivative evaluated at given data points.

Definition at line 710 of file Polynomial.h.

§ Evaluate1stOrderDerivative() [4/5]

double mirtk::Polynomial::Evaluate1stOrderDerivative ( int  j,
const Point x,
bool  twoD = false 
) const
inline

Evaluate 1st order partial derivative of polynomial

Parameters
[in]jIndex of independent variable w.r.t. which the derivative is taken.
[in]xData point. The dimension of the model must be 2 or 3.
[in]twoDWhether to ignore z coordinate.
Returns
Value of 1st order derivative evaluated at given data point.

Definition at line 717 of file Polynomial.h.

§ Evaluate1stOrderDerivative() [5/5]

double mirtk::Polynomial::Evaluate1stOrderDerivative ( int  j,
double  x 
) const
inline

Evaluate 1st order partial derivative of polynomial

Parameters
[in]jIndex of independent variable w.r.t. which the derivative is taken.
[in]xData point. The dimension of the model must be 1.
Returns
Value of 1st order derivative evaluated at given data point.

Definition at line 729 of file Polynomial.h.

§ Evaluate2ndOrderDerivative() [1/5]

Vector mirtk::Polynomial::Evaluate2ndOrderDerivative ( int  j1,
int  j2,
const Matrix x 
) const

Evaluate 2nd order partial derivative of polynomial

Parameters
[in]xMatrix of size (n x p), where n is the number of data points to evaluate, and p is the dimension of the independent variable space of the polynomial model.
[in]j1Index of independent variable w.r.t. which the 1st derivative is taken.
[in]j2Index of independent variable w.r.t. which the 2nd derivative is taken.
Returns
Values of 2nd order derivative evaluated at given data points.

§ Evaluate2ndOrderDerivative() [2/5]

Vector mirtk::Polynomial::Evaluate2ndOrderDerivative ( int  j1,
int  j2,
const PointSet x,
bool  twoD = false 
) const
inline

Evaluate 2nd order partial derivative of polynomial

Parameters
[in]j1Index of independent variable w.r.t. which the 1st derivative is taken.
[in]j2Index of independent variable w.r.t. which the 2nd derivative is taken.
[in]xData points. The dimension of the model must be 2 or 3.
[in]twoDWhether to ignore z coordinate.
Returns
Values of 2nd order derivative evaluated at given data points.

Definition at line 742 of file Polynomial.h.

§ Evaluate2ndOrderDerivative() [3/5]

Vector mirtk::Polynomial::Evaluate2ndOrderDerivative ( int  j1,
int  j2,
const Vector x 
) const
inline

Evaluate 2nd order partial derivative of polynomial

Parameters
[in]j1Index of independent variable w.r.t. which the 1st derivative is taken.
[in]j2Index of independent variable w.r.t. which the 2nd derivative is taken.
[in]xValues of independent variable. The dimension of the model must be 1.
Returns
Values of 2nd order derivative evaluated at given data points.

Definition at line 750 of file Polynomial.h.

§ Evaluate2ndOrderDerivative() [4/5]

double mirtk::Polynomial::Evaluate2ndOrderDerivative ( int  j1,
int  j2,
const Point x,
bool  twoD = false 
) const
inline

Evaluate 2nd order partial derivative of polynomial

Parameters
[in]j1Index of independent variable w.r.t. which the 1st derivative is taken.
[in]j2Index of independent variable w.r.t. which the 2nd derivative is taken.
[in]xData point. The dimension of the model must be 2 or 3.
[in]twoDWhether to ignore z coordinate.
Returns
Value of 2nd order derivative evaluated at given data point.

Definition at line 757 of file Polynomial.h.

§ Evaluate2ndOrderDerivative() [5/5]

double mirtk::Polynomial::Evaluate2ndOrderDerivative ( int  j1,
int  j2,
double  x 
) const
inline

Evaluate 2nd order partial derivative of polynomial

Parameters
[in]j1Index of independent variable w.r.t. which the 1st derivative is taken.
[in]j2Index of independent variable w.r.t. which the 2nd derivative is taken.
[in]xData point. The dimension of the model must be 1.
Returns
Value of 2nd order derivative evaluated at given data point.

Definition at line 769 of file Polynomial.h.

§ EvaluateGaussianCurvature()

double mirtk::Polynomial::EvaluateGaussianCurvature ( const Point x) const

Evaluate Gaussian curvature of implicit polynomial surface

Ron Goldman, Curvature formulas for implicit curves and surfaces, Computer Aided Geometric Design 22 (2005) 632–658.

See also
http://www.cgeo.ulg.ac.be/CAO/Goldman_Curvature_formulas_implicit.pdf
Parameters
[in]xData point. The dimension of the model must be 3.
Returns
Gaussian curvature of implicit surface at x.

§ EvaluateGradient()

Vector3 mirtk::Polynomial::EvaluateGradient ( const Point x) const

Evaluate gradient of 3D polynomial

Parameters
[in]xData point. The dimension of the model must be 3.
Returns
Values of 1st order derivatives evaluated at given data point.

§ EvaluateHessian()

Matrix3x3 mirtk::Polynomial::EvaluateHessian ( const Point x) const

Evaluate Hessian of 3D polynomial

Parameters
[in]xData point. The dimension of the model must be 3.
Returns
Values of 2nd order derivatives evaluated at given data point.

§ EvaluateMeanCurvature()

double mirtk::Polynomial::EvaluateMeanCurvature ( const Point x) const

Evaluate mean curvature of implicit polynomial surface

Ron Goldman, Curvature formulas for implicit curves and surfaces, Computer Aided Geometric Design 22 (2005) 632–658.

See also
http://www.cgeo.ulg.ac.be/CAO/Goldman_Curvature_formulas_implicit.pdf
Parameters
[in]xData point. The dimension of the model must be 3.
Returns
Mean curvature of implicit surface at x.

§ EvaluateTaubinDistance()

double mirtk::Polynomial::EvaluateTaubinDistance ( const Point x) const

Compute Taubin distance of a point to the implicit polynomial surface

The Taubin distance is the agebraic distance, i.e., the value of the implicit polynomial function at x, divided the norm of its gradient. It is a first-order approximation to the Euclidean distance of the point to the closest point on the surface.

Parameters
[in]xData point. The dimension of the model must be 3.
Returns
Taubin distance of the point to the surface.

§ Exponent()

int mirtk::Polynomial::Exponent ( int  i,
int  j = 0 
) const
inline

Get exponent of independent variable in specified model term

Parameters
[in]iIndex of model term.
[in]jIndex of independent variable.
Returns
Exponent of j-th independent variable in i-th model term.

Definition at line 565 of file Polynomial.h.

§ Fit() [1/5]

double mirtk::Polynomial::Fit ( const Matrix x,
const Vector y 
)

Fits polynomial regression model to one or more independent variables

Parameters
[in]xValues of independent variables, a matrix of size (n x p), where n is the number of data points and p is the dimension of the independent variable space.
[in]yValues of dependent variable.
Returns
RMS error of the regression.

§ Fit() [2/5]

double mirtk::Polynomial::Fit ( const Matrix x,
const Vector y,
const Array< int > &  subset 
)

Fits polynomial regression model to one or more independent variables

Parameters
[in]xValues of independent variables, a matrix of size (n x p), where n is the number of data points and p is the dimension of the independent variable space.
[in]subsetIndices of points to use for fitting.
[in]yValues of dependent variable.
Returns
RMS error of the regression.

§ Fit() [3/5]

double mirtk::Polynomial::Fit ( const Matrix x,
const Vector y,
const OrderedSet< int > &  subset 
)

Fits polynomial regression model to one or more independent variables

Parameters
[in]xValues of independent variables, a matrix of size (n x p), where n is the number of data points and p is the dimension of the independent variable space.
[in]subsetIndices of points to use for fitting.
[in]yValues of dependent variable.
Returns
RMS error of the regression.

§ Fit() [4/5]

double mirtk::Polynomial::Fit ( const PointSet x,
const Vector y,
bool  twoD = false 
)
inline

Fits polynomial regression model to one or more independent variables

Parameters
[in]xValues of independent variables. The dimension of the independent variable space is 2 or 3.
[in]yValues of dependent variable.
[in]twoDWhether to ignore z coordinate.
Returns
RMS error of the regression.

Definition at line 625 of file Polynomial.h.

§ Fit() [5/5]

double mirtk::Polynomial::Fit ( const Vector x,
const Vector y 
)
inline

Fits polynomial regression model to one independent variable

Parameters
[in]xValues of independent variable.
[in]yValues of dependent variable.
Returns
RMS error of the regression.

Definition at line 631 of file Polynomial.h.

§ FitSurface() [1/6]

double mirtk::Polynomial::FitSurface ( const PointSet x)

Fits polynomial surface model to 3D point cloud

The dependent variable of the surface model is the algebraic distance of a point from the surface. This function sets the coefficients of constant model term(s) to 1 and excludes them from the fit to avoid the trivial solution of the homogeneous linear system of equations.

Parameters
[in]xPoints on surface.
Returns
RMS error of the regression.

§ FitSurface() [2/6]

double mirtk::Polynomial::FitSurface ( const PointSet x,
const Array< int > &  subset 
)

Fits polynomial surface model to subset of 3D point cloud

The dependent variable of the surface model is the algebraic distance of a point from the surface. This function sets the coefficients of constant model term(s) to 1 and excludes them from the fit to avoid the trivial solution of the homogeneous linear system of equations.

Parameters
[in]xPoints on surface.
[in]subsetIndices of points to use for fitting.
Returns
RMS error of the regression.

§ FitSurface() [3/6]

double mirtk::Polynomial::FitSurface ( const PointSet x,
const OrderedSet< int > &  subset 
)

Fits polynomial surface model to subset of 3D point cloud

The dependent variable of the surface model is the algebraic distance of a point from the surface. This function sets the coefficients of constant model term(s) to 1 and excludes them from the fit to avoid the trivial solution of the homogeneous linear system of equations.

Parameters
[in]xPoints on surface.
[in]subsetIndices of points to use for fitting.
Returns
RMS error of the regression.

§ FitSurface() [4/6]

double mirtk::Polynomial::FitSurface ( const PointSet x,
const PointSet n,
double  c = 1.0 
)

Fits polynomial surface model to 3D point cloud

The dependent variable of the surface model is the algebraic distance of a point from the surface.

Parameters
[in]xPoints on surface.
[in]nSurface normals at input points.
[in]cOffset along normal direction for points inside and outside the surface to be modelled.
Returns
RMS error of the regression.

§ FitSurface() [5/6]

double mirtk::Polynomial::FitSurface ( const PointSet x,
const PointSet n,
const Array< int > &  subset,
double  c = 1.0 
)

Fits polynomial surface model to subset of 3D point cloud

The dependent variable of the surface model is the distance of a point from the surface.

Parameters
[in]xPoints on surface.
[in]nSurface normals at input points.
[in]subsetIndices of points to use for fitting.
[in]cOffset along normal direction for points inside and outside the surface to be modelled.
Returns
RMS error of the regression.

§ FitSurface() [6/6]

double mirtk::Polynomial::FitSurface ( const PointSet x,
const PointSet n,
const OrderedSet< int > &  subset,
double  c = 1.0 
)

Fits polynomial surface model to subset of 3D point cloud

The dependent variable of the surface model is the distance of a point from the surface.

Parameters
[in]xPoints on surface.
[in]nSurface normals at input points.
[in]subsetIndices of points to use for fitting.
[in]cOffset along normal direction for points inside and outside the surface to be modelled.
Returns
RMS error of the regression.

§ Initialize()

int mirtk::Polynomial::Initialize ( int  p,
int  order = 0 
)

Build complete polynomial regression model of given order

Parameters
[in]pDimension of independent variable space.
[in]orderOrder of polynomial model, i.e., highest model term exponent. When non-positive, the current order of the model is used.
Returns
Number of model terms.

§ IsConstant()

bool mirtk::Polynomial::IsConstant ( int  i) const
inline

Whether i-th term is a constant term

Parameters
[in]iIndex of model term.
Returns
Whether all exponents of i-th term are zero.

Definition at line 573 of file Polynomial.h.

§ SetConstantCoefficient()

void mirtk::Polynomial::SetConstantCoefficient ( double  value,
enum Status  status = Passive 
)

Sets coefficient(s) of constant model terms

Parameters
[in]valueCoefficient value.
[in]statusStatus of constant model terms. Set to Passive by default, i.e., constant terms are fixed for model fitting.

§ Status() [1/2]

void mirtk::Polynomial::Status ( int  i,
enum Status  s 
)
inline

Set status of i-th coefficient

Parameters
[in]iIndex of coefficient.
[in]sStatus of coefficient.

Definition at line 601 of file Polynomial.h.

§ Status() [2/2]

enum Status mirtk::Polynomial::Status ( int  i) const
inline

Get status of i-th coefficient

Parameters
[in]iIndex of coefficient.
Returns
Status of i-th coefficient.

Definition at line 608 of file Polynomial.h.


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