From 680344945f84364fbbcbe4d4a353a52d4a724653 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 16 Jul 2008 21:36:19 +0000 Subject: update to latest 2geom (rev1497) (bzr r6332) --- src/2geom/numeric/fitting-model.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/2geom/numeric') diff --git a/src/2geom/numeric/fitting-model.h b/src/2geom/numeric/fitting-model.h index cc3113372..de8f24760 100644 --- a/src/2geom/numeric/fitting-model.h +++ b/src/2geom/numeric/fitting-model.h @@ -41,6 +41,7 @@ #include <2geom/bezier-curve.h> #include <2geom/poly.h> #include <2geom/ellipse.h> +#include <2geom/circle.h> #include <2geom/utils.h> @@ -239,6 +240,41 @@ class LFMEllipse }; +// 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 circle curve +template< typename InstanceType > +class LFMCircleEquation + : public LinearFittingModelWithFixedTerms +{ + public: + void feed( VectorView & coeff, double & fixed_term, Point const& p ) const + { + coeff[0] = p[X]; + coeff[1] = p[Y]; + coeff[2] = 1; + fixed_term = p[X] * p[X] + p[Y] * p[Y]; + } + + size_t size() const + { + return 3; + } +}; + + +// this model generates Ellipse curves +class LFMCircle + : public LFMCircleEquation +{ + public: + void instance(Circle & c, ConstVectorView const& coeff) const + { + c.set(1, coeff[0], coeff[1], coeff[2]); + } +}; + + // this model generates SBasis objects class LFMSBasis : public LinearFittingModel -- cgit v1.2.3