summaryrefslogtreecommitdiffstats
path: root/src/2geom/numeric
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-07-16 21:36:19 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-07-16 21:36:19 +0000
commit680344945f84364fbbcbe4d4a353a52d4a724653 (patch)
tree1e8f541be4d451eff0e58ec6d76e066dd3167086 /src/2geom/numeric
parentimproving SVG Fonts UI (diff)
downloadinkscape-680344945f84364fbbcbe4d4a353a52d4a724653.tar.gz
inkscape-680344945f84364fbbcbe4d4a353a52d4a724653.zip
update to latest 2geom (rev1497)
(bzr r6332)
Diffstat (limited to 'src/2geom/numeric')
-rw-r--r--src/2geom/numeric/fitting-model.h36
1 files changed, 36 insertions, 0 deletions
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<Point, double, InstanceType>
+{
+ 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<Circle>
+{
+ 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<double, double, SBasis>