#include <Polynomial.h>
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. | |
Polynomial & | operator= (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) |
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.
Definition at line 47 of file Polynomial.h.
mirtk::Polynomial::Polynomial | ( | int | order = 2 | ) |
Constructor
[in] | order | Order of the polynomial, i.e., highest model term exponent. |
Construct complete polynomial
[in] | p | Dimension of independent variable space. |
[in] | order | Order of the polynomial, i.e., highest model term exponent. |
[in] | coeff | Coefficients 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. |
|
inline |
Set coefficient of i-th term
[in] | i | Index of model term. |
[in] | c | Model term coefficient. |
Definition at line 587 of file Polynomial.h.
|
inline |
Get coefficient of i-th term
[in] | i | Index of model term. |
Definition at line 594 of file Polynomial.h.
|
inline |
Set coefficients of polynomial model terms
[in] | coeff | Coefficient vector of length NumberOfTerms(). |
Definition at line 580 of file Polynomial.h.
Evaluates polynomial for n p-dimensional data points
[in] | x | Matrix 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. |
Evaluates polynomial for n 2- or 3-dimensional data points
[in] | x | Data points. The dimension of the model must be 2 or 3. |
[in] | twoD | Whether to ignore z coordinate. |
Definition at line 641 of file Polynomial.h.
Evaluates polynomial for n 1-dimensional data points
[in] | x | Values of independent variable. The dimension of the model must be 1. |
Definition at line 649 of file Polynomial.h.
|
inline |
Evaluates polynomial for one 3D point
[in] | x | Data point. The dimension of the model must be 2 or 3. |
[in] | twoD | Whether to ignore z coordinate. |
Definition at line 656 of file Polynomial.h.
|
inline |
Evaluates polynomial for one 3D point
[in] | x | First point coordinate. |
[in] | y | Second point coordinate. |
[in] | z | Third point coordinate. |
Definition at line 668 of file Polynomial.h.
|
inline |
Evaluates polynomial for one 2D point
[in] | x | First point coordinate. |
[in] | y | Second point coordinate. |
Definition at line 679 of file Polynomial.h.
|
inline |
Evaluates polynomial for one independent variable value
[in] | x | Data point. The dimension of the model must be 1. |
Definition at line 689 of file Polynomial.h.
Evaluate 1st order partial derivative of polynomial
[in] | j | Index of independent variable w.r.t. which the derivative is taken. |
[in] | x | Matrix 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. |
|
inline |
Evaluate 1st order partial derivative of polynomial
[in] | j | Index of independent variable w.r.t. which the derivative is taken. |
[in] | x | Data points. The dimension of the model must be 2 or 3. |
[in] | twoD | Whether to ignore z coordinate. |
Definition at line 702 of file Polynomial.h.
Evaluate 1st order partial derivative of polynomial
[in] | j | Index of independent variable w.r.t. which the derivative is taken. |
[in] | x | Values of independent variable. The dimension of the model must be 1. |
Definition at line 710 of file Polynomial.h.
|
inline |
Evaluate 1st order partial derivative of polynomial
[in] | j | Index of independent variable w.r.t. which the derivative is taken. |
[in] | x | Data point. The dimension of the model must be 2 or 3. |
[in] | twoD | Whether to ignore z coordinate. |
Definition at line 717 of file Polynomial.h.
|
inline |
Evaluate 1st order partial derivative of polynomial
[in] | j | Index of independent variable w.r.t. which the derivative is taken. |
[in] | x | Data point. The dimension of the model must be 1. |
Definition at line 729 of file Polynomial.h.
Evaluate 2nd order partial derivative of polynomial
[in] | x | Matrix 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] | j1 | Index of independent variable w.r.t. which the 1st derivative is taken. |
[in] | j2 | Index of independent variable w.r.t. which the 2nd derivative is taken. |
|
inline |
Evaluate 2nd order partial derivative of polynomial
[in] | j1 | Index of independent variable w.r.t. which the 1st derivative is taken. |
[in] | j2 | Index of independent variable w.r.t. which the 2nd derivative is taken. |
[in] | x | Data points. The dimension of the model must be 2 or 3. |
[in] | twoD | Whether to ignore z coordinate. |
Definition at line 742 of file Polynomial.h.
|
inline |
Evaluate 2nd order partial derivative of polynomial
[in] | j1 | Index of independent variable w.r.t. which the 1st derivative is taken. |
[in] | j2 | Index of independent variable w.r.t. which the 2nd derivative is taken. |
[in] | x | Values of independent variable. The dimension of the model must be 1. |
Definition at line 750 of file Polynomial.h.
|
inline |
Evaluate 2nd order partial derivative of polynomial
[in] | j1 | Index of independent variable w.r.t. which the 1st derivative is taken. |
[in] | j2 | Index of independent variable w.r.t. which the 2nd derivative is taken. |
[in] | x | Data point. The dimension of the model must be 2 or 3. |
[in] | twoD | Whether to ignore z coordinate. |
Definition at line 757 of file Polynomial.h.
|
inline |
Evaluate 2nd order partial derivative of polynomial
[in] | j1 | Index of independent variable w.r.t. which the 1st derivative is taken. |
[in] | j2 | Index of independent variable w.r.t. which the 2nd derivative is taken. |
[in] | x | Data point. The dimension of the model must be 1. |
Definition at line 769 of file Polynomial.h.
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.
[in] | x | Data point. The dimension of the model must be 3. |
x
. Evaluate gradient of 3D polynomial
[in] | x | Data point. The dimension of the model must be 3. |
Matrix3x3 mirtk::Polynomial::EvaluateHessian | ( | const Point & | x | ) | const |
Evaluate Hessian of 3D polynomial
[in] | x | Data point. The dimension of the model must be 3. |
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.
[in] | x | Data point. The dimension of the model must be 3. |
x
. 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.
[in] | x | Data point. The dimension of the model must be 3. |
|
inline |
Get exponent of independent variable in specified model term
[in] | i | Index of model term. |
[in] | j | Index of independent variable. |
Definition at line 565 of file Polynomial.h.
Fits polynomial regression model to one or more independent variables
[in] | x | Values 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] | y | Values of dependent variable. |
Fits polynomial regression model to one or more independent variables
[in] | x | Values 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] | subset | Indices of points to use for fitting. |
[in] | y | Values of dependent variable. |
double mirtk::Polynomial::Fit | ( | const Matrix & | x, |
const Vector & | y, | ||
const OrderedSet< int > & | subset | ||
) |
Fits polynomial regression model to one or more independent variables
[in] | x | Values 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] | subset | Indices of points to use for fitting. |
[in] | y | Values of dependent variable. |
Fits polynomial regression model to one or more independent variables
[in] | x | Values of independent variables. The dimension of the independent variable space is 2 or 3. |
[in] | y | Values of dependent variable. |
[in] | twoD | Whether to ignore z coordinate. |
Definition at line 625 of file Polynomial.h.
Fits polynomial regression model to one independent variable
[in] | x | Values of independent variable. |
[in] | y | Values of dependent variable. |
Definition at line 631 of file Polynomial.h.
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.
[in] | x | Points on surface. |
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.
[in] | x | Points on surface. |
[in] | subset | Indices of points to use for fitting. |
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.
[in] | x | Points on surface. |
[in] | subset | Indices of points to use for fitting. |
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.
[in] | x | Points on surface. |
[in] | n | Surface normals at input points. |
[in] | c | Offset along normal direction for points inside and outside the surface to be modelled. |
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.
[in] | x | Points on surface. |
[in] | n | Surface normals at input points. |
[in] | subset | Indices of points to use for fitting. |
[in] | c | Offset along normal direction for points inside and outside the surface to be modelled. |
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.
[in] | x | Points on surface. |
[in] | n | Surface normals at input points. |
[in] | subset | Indices of points to use for fitting. |
[in] | c | Offset along normal direction for points inside and outside the surface to be modelled. |
int mirtk::Polynomial::Initialize | ( | int | p, |
int | order = 0 |
||
) |
Build complete polynomial regression model of given order
[in] | p | Dimension of independent variable space. |
[in] | order | Order of polynomial model, i.e., highest model term exponent. When non-positive, the current order of the model is used. |
|
inline |
Whether i-th term is a constant term
[in] | i | Index of model term. |
Definition at line 573 of file Polynomial.h.
void mirtk::Polynomial::SetConstantCoefficient | ( | double | value, |
enum Status | status = Passive |
||
) |
Sets coefficient(s) of constant model terms
[in] | value | Coefficient value. |
[in] | status | Status of constant model terms. Set to Passive by default, i.e., constant terms are fixed for model fitting. |
|
inline |
Set status of i-th coefficient
[in] | i | Index of coefficient. |
[in] | s | Status of coefficient. |
Definition at line 601 of file Polynomial.h.
|
inline |
Get status of i-th coefficient
[in] | i | Index of coefficient. |
Definition at line 608 of file Polynomial.h.