diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2011-02-02 21:24:36 +0000 |
|---|---|---|
| committer | Johan Engelen <goejendaagh@zonnet.nl> | 2011-02-02 21:24:36 +0000 |
| commit | 53933f5fea9d07d1ba6304b88439fba257ee8c34 (patch) | |
| tree | 21f94cd05346fc1236751bb1db3e0850e5aece54 /src/2geom/numeric/fitting-model.h | |
| parent | Translations. French translation minor update. (diff) | |
| download | inkscape-53933f5fea9d07d1ba6304b88439fba257ee8c34.tar.gz inkscape-53933f5fea9d07d1ba6304b88439fba257ee8c34.zip | |
update to latest 2geom !
(bzr r10025)
Diffstat (limited to 'src/2geom/numeric/fitting-model.h')
| -rw-r--r-- | src/2geom/numeric/fitting-model.h | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/src/2geom/numeric/fitting-model.h b/src/2geom/numeric/fitting-model.h index dcf0e8e1d..b1ecbe92c 100644 --- a/src/2geom/numeric/fitting-model.h +++ b/src/2geom/numeric/fitting-model.h @@ -43,6 +43,7 @@ #include <2geom/ellipse.h> #include <2geom/circle.h> #include <2geom/utils.h> +#include <2geom/conicsec.h> namespace Geom { namespace NL { @@ -83,6 +84,10 @@ namespace Geom { namespace NL { * instance type: the type of the objects produced by using * the fitting raw data solution */ + + + + template< typename ParameterType, typename ValueType, typename InstanceType > class LinearFittingModel { @@ -230,8 +235,32 @@ class LFMNormalizedPowerBasis // incomplete model, it can be inherited to make up different kinds of // instance type; the raw data is a vector of coefficients of the equation // of an ellipse curve +//template< typename InstanceType > +//class LFMEllipseEquation +// : public LinearFittingModelWithFixedTerms<Point, double, InstanceType> +//{ +// public: +// void feed( VectorView & coeff, double & fixed_term, Point const& p ) const +// { +// coeff[0] = p[X] * p[Y]; +// coeff[1] = p[Y] * p[Y]; +// coeff[2] = p[X]; +// coeff[3] = p[Y]; +// coeff[4] = 1; +// fixed_term = p[X] * p[X]; +// } +// +// size_t size() const +// { +// return 5; +// } +//}; + +// incomplete model, it can be inherited to make up different kinds of +// instance type; the raw data is a vector of coefficients of the equation +// of a conic section template< typename InstanceType > -class LFMEllipseEquation +class LFMConicEquation : public LinearFittingModelWithFixedTerms<Point, double, InstanceType> { public: @@ -251,10 +280,20 @@ class LFMEllipseEquation } }; +// this model generates Ellipse curves +class LFMConicSection + : public LFMConicEquation<xAx> +{ + public: + void instance(xAx & c, ConstVectorView const& coeff) const + { + c.set(1, coeff[0], coeff[1], coeff[2], coeff[3], coeff[4]); + } +}; // this model generates Ellipse curves class LFMEllipse - : public LFMEllipseEquation<Ellipse> + : public LFMConicEquation<Ellipse> { public: void instance(Ellipse & e, ConstVectorView const& coeff) const @@ -431,9 +470,8 @@ class LFMBezier // this model generates Bezier curves -template< unsigned int N > class LFMBezierCurve - : public LinearFittingModel< double, Point, BezierCurve<N> > + : public LinearFittingModel< double, Point, BezierCurve > { public: LFMBezierCurve( size_t _order ) @@ -451,13 +489,13 @@ class LFMBezierCurve return mob.size(); } - void instance(BezierCurve<N> & bc, ConstMatrixView const& raw_data) const + void instance(BezierCurve & bc, ConstMatrixView const& raw_data) const { Bezier bx(size()-1); Bezier by(size()-1); mob.instance(bx, raw_data.column_const_view(X)); mob.instance(by, raw_data.column_const_view(Y)); - bc = BezierCurve<N>(bx, by); + bc = BezierCurve(bx, by); } private: |
