From 49fcd0bcac545a6f7df372fbfd44a05ffb103262 Mon Sep 17 00:00:00 2001 From: koldo Date: Fri, 20 Feb 2015 22:45:42 +0000 Subject: [PATCH] ScatterDraw: Improved initial coefficients guessing git-svn-id: svn://ultimatepp.org/upp/trunk@8190 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ScatterDraw/Equation.h | 7 ++++++- uppsrc/ScatterDraw/ScatterDraw.t | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/uppsrc/ScatterDraw/Equation.h b/uppsrc/ScatterDraw/Equation.h index bff44cad2..60e03daea 100644 --- a/uppsrc/ScatterDraw/Equation.h +++ b/uppsrc/ScatterDraw/Equation.h @@ -95,8 +95,13 @@ public: virtual String GetName() {return t_("Polynomial");} virtual String GetFullName() {return t_("Polynomial") + String(" n = ") + FormatInt(degree);} virtual String GetEquation(int numDigits = 3); - virtual void GuessCoeff(DataSource &series) {coeff[0] = series.AvgY();} void SetDegree(int num) {degree = num; SetNumCoeff(num + 1);} + virtual void GuessCoeff(DataSource &series) { + coeff[0] = series.AvgY(); + int realDegree = degree; + for (degree = 2; degree < realDegree; degree++) + Fit(series); + } }; class PolynomialEquation2 : public PolynomialEquation { diff --git a/uppsrc/ScatterDraw/ScatterDraw.t b/uppsrc/ScatterDraw/ScatterDraw.t index 453c04483..e6b228586 100644 --- a/uppsrc/ScatterDraw/ScatterDraw.t +++ b/uppsrc/ScatterDraw/ScatterDraw.t @@ -62,4 +62,3 @@ caES("Racional_1") esES("Racional_1") euES("") frFR("") -