20 #ifndef MIRTK_Polynomial_H 21 #define MIRTK_Polynomial_H 23 #include "mirtk/Object.h" 25 #include "mirtk/Assert.h" 26 #include "mirtk/Array.h" 27 #include "mirtk/Status.h" 28 #include "mirtk/Vector.h" 29 #include "mirtk/Vector3.h" 30 #include "mirtk/Matrix.h" 31 #include "mirtk/Matrix3x3.h" 32 #include "mirtk/PointSet.h" 33 #include "mirtk/OrderedSet.h" 55 mirtkReadOnlyAttributeMacro(
int, Order);
58 mirtkReadOnlyAttributeMacro(
int,
Dimension);
64 mirtkReadOnlyAttributeMacro(
Matrix, ModelTerms);
70 mirtkAttributeMacro(Array<enum Status>,
Status);
127 int Exponent(
int i,
int j = 0)
const;
165 enum Status
Status(
int i)
const;
200 double Fit(
const Matrix &x,
const Vector &y,
const Array<int> &subset);
211 double Fit(
const Matrix &x,
const Vector &y,
const OrderedSet<int> &subset);
295 const Array<int> &subset,
double c = 1.0);
310 const OrderedSet<int> &subset,
double c = 1.0);
354 double Evaluate(
double x,
double y,
double z)
const;
362 double Evaluate(
double x,
double y)
const;
545 return _ModelTerms.Rows();
553 if (
Status(i) == Passive) ++n;
567 mirtkAssert(i <
NumberOfTerms(),
"model term index is within bounds");
568 mirtkAssert(j < _Dimension,
"variable index is within bounds");
569 return static_cast<int>(_ModelTerms(i, j));
575 mirtkAssert(i <
NumberOfTerms(),
"model term index is within bounds");
576 return (_ModelTerms.RowSum(i) == .0);
582 mirtkAssert(coeff.
Rows() ==
NumberOfTerms(),
"coefficient vector has element for each term");
583 _Coefficients = coeff;
589 mirtkAssert(i <
NumberOfTerms(),
"model term index is within bounds");
590 _Coefficients(i) = c;
596 mirtkAssert(i <
NumberOfTerms(),
"model term index is within bounds");
597 return _Coefficients(i);
603 mirtkAssert(i <
NumberOfTerms(),
"coefficient index is within bounds");
610 mirtkAssert(i <
NumberOfTerms(),
"coefficient index is within bounds");
643 mirtkAssert(twoD ? _Dimension == 2 : _Dimension == 3,
644 "dimension of independent variable space must be " << (twoD ? 2 : 3));
651 mirtkAssert(_Dimension == 1,
"dimension of independent variable space must be 1");
658 mirtkAssert(twoD ? _Dimension == 2 : _Dimension == 3,
659 "dimension of independent variable space must be " << (twoD ? 2 : 3));
660 Matrix x(1, twoD ? 2 : 3);
663 if (!twoD) x(0, 2) = p.
_z;
670 mirtkAssert(_Dimension == 3,
"dimension of independent variable space must be 3");
681 mirtkAssert(_Dimension == 2,
"dimension of independent variable space must be 2");
691 mirtkAssert(_Dimension == 1,
"dimension of independent variable space must be 1");
704 mirtkAssert(twoD ? _Dimension == 2 : _Dimension == 3,
705 "dimension of independent variable space must be " << (twoD ? 2 : 3));
712 mirtkAssert(_Dimension == 1,
"dimension of independent variable space must be 1");
719 mirtkAssert(twoD ? _Dimension == 2 : _Dimension == 3,
720 "dimension of independent variable space must be " << (twoD ? 2 : 3));
721 Matrix x(1, twoD ? 2 : 3);
724 if (!twoD) x(0, 2) = p.
_z;
731 mirtkAssert(_Dimension == 1,
"dimension of independent variable space must be 1");
744 mirtkAssert(twoD ? _Dimension == 2 : _Dimension == 3,
745 "dimension of independent variable space must be " << (twoD ? 2 : 3));
752 mirtkAssert(_Dimension == 1,
"dimension of independent variable space must be 1");
759 mirtkAssert(twoD ? _Dimension == 2 : _Dimension == 3,
760 "dimension of independent variable space must be " << (twoD ? 2 : 3));
761 Matrix x(1, twoD ? 2 : 3);
764 if (!twoD) x(0, 2) = p.
_z;
771 mirtkAssert(_Dimension == 1,
"dimension of independent variable space must be 1");
790 #endif // MIRTK_Polynomial_H double Fit(const Matrix &x, const Vector &y)
void SetConstantCoefficient(double value, enum Status status=Passive)
double FitSurface(const PointSet &x)
virtual ~Polynomial()
Destructor.
double EvaluateGaussianCurvature(const Point &x) const
double _x
x coordinate of Point
double EvaluateMeanCurvature(const Point &x) const
Matrix3x3 EvaluateHessian(const Point &x) const
Vector Evaluate(const Matrix &x) const
Polynomial & operator=(const Polynomial &)
Assignment operator.
int Exponent(int i, int j=0) const
Vector3 EvaluateGradient(const Point &x) const
Status
Enumeration of common states for entities such as objective function parameters.
int Rows() const
Returns number of rows.
int Dimension(vtkDataSet *)
Determine dimension of data set.
int NumberOfPassiveTerms() const
Number of passive model terms/coefficients.
void Coefficient(int i, double c)
bool IsConstant(int i) const
void SetCoefficientsToZero()
Set all model coefficients to zero.
int Initialize(int p, int order=0)
int NumberOfTerms() const
Number of model terms/coefficients.
Vector Evaluate1stOrderDerivative(int j, const Matrix &x) const
void Coefficients(const Vector &coeff)
int NumberOfActiveTerms() const
Number of active model terms/coefficients.
ostream & Print(ostream &os, Indent=0) const
Print polynomial model equation.
double _z
z coordinate of Point
double _y
y coordinate of Point
double EvaluateTaubinDistance(const Point &x) const
Vector Evaluate2ndOrderDerivative(int j1, int j2, const Matrix &x) const
void Status(int i, enum Status s)