Ok, I'm going to write interpolation method from scratch, because built-in fitter is not enough for me (it's quite poor i think), but anyway, thanks for response
Ok, I'm going to write interpolation method from scratch, because built-in fitter is not enough for me (it's quite poor i think), but anyway, thanks for response
As far as I can see you didn't succeed to use the QwtCurveFitter API ( guess you missed to enable the QwtPlotCurve::Fitted attribute, or didn't adjust the spline size.) . If frustration about this is the reason for your "poor", well ...
If your statement is because you have checked the implementation, please elaborate, why spline interpolation ( this is a very common way of interpolation ) isn't a solution for you situation.
QwtCurveFitter is an abstract API and you can implement any other fitting algorithm as well ( f.e. in 5.3 you find an implementation of the Douglas/Peucker algorithm ). So if you know other/better strategies for curve fitting I'm interested to add them to the Qwt lib.
Uwe
What about Cardinal/Cubic Spline? The cubic spline is used in OpenOffice and it works quite good. I tested cardinal spline also, and results was much better than default qwt fitter
It sounds good - can you provide simple example how to do this?Originally Posted by Uwe
Last edited by giaur; 1st December 2009 at 09:50.
QwtSplineCurveFitter is an implementation of a cubic spline - are you sure, that you successfully enabled spline interpolation for your curve ?What about Cardinal/Cubic Spline? The cubic spline is used in OpenOffice and it works quite good.
You didn't explain why you want to have curve interpolation. If your motivation is to paint smoother curves it's obvious, that interpolation needs to be done for the translated points ( in widget coordinates ) - not for the points in application coordinates.
If you want to interpolate the translated points (see above) you must derive from QwtCurveFitter and implement YourFitter::fitCurve(). Please send me the code of your cardinal spline class or something else if you think it is valuable for others.It sounds good - can you provide simple example how to do this?
But initializing your curve with your individual fitter requires the same steps you have to do for QwtSplineCurveFitter. So I recommend to check if the bad results of the interpolation are really because of the implemented interpolation algorithm. If true I would be interested in your curve points for further investigations.
Maybe it helps to check the curvdemo2 example, that shows how to enable interpolation ( don't forget the QwtPlotCurve::Fitted attribute).
Uwe
Last edited by Uwe; 2nd December 2009 at 08:42. Reason: spelling error
I'm sure they are.Originally Posted by Uwe
I've made simple test. My data points are:
0, 17
1, 16.5
2, 8
4, 3
5, 12
8, 14.5
And look at the plot screenshot:
Legend:
- blue: without spline
- green: parametric spline (built in)
- red: cardinal spline, tangentStrength=0.35
Built-in cubic spline (entirely unacceptable for me):
And, finally - cubic spline from open office for the same points:
I'm not really sure what alghoritm exactly is used in Open Office, but this is much better, than your cubic spline implementation, and it seems to be better, than cardinal spline I used.
Last edited by giaur; 2nd December 2009 at 17:27.
I tried your points with the following code:
Qt Code:
#include <qapplication.h> #include <qwt_plot.h> #include <qwt_plot_curve.h> #include <qwt_curve_fitter.h> #include <qwt_symbol.h> int main(int argc, char **argv) { QwtPlot plot; plot.setCanvasBackground(Qt::white); plot.resize(600,400); plot.show(); const double x[] = { 0, 1, 2, 4, 5, 8 }; const double y[] = { 17, 16.5, 8, 3, 12, 14.5 }; // Insert new curves QwtSymbol symbol; symbol.setSize(10, 10); symbol.setBrush(color); curve->setSymbol(symbol); fitter->setSplineSize(100); curve->setCurveFitter(fitter); curve->setData(x, y, 6); curve->attach(&plot); return a.exec(); }To copy to clipboard, switch view to plain text mode
The result is different compared to the OpenOffice curve, but what exactly makes you so unhappy with it ?
Uwe
PS: You can play with the spline size parameter. IMHO the curve looks better with a value of 50.
Ok, parametric spline is quite good - it looks the same as on my screenshot. But there is still some effect which I neew to minimalize - I need only edges round, and minimal curve peeks. For cardinal spline, there is parametr called tangentStrength and I can play with it to get bes results.
I simply need the situation, when maximum/minimum data point is curve maximum/minimum (ideally) and cardinal spline in my screen looks better here
Last edited by giaur; 2nd December 2009 at 19:12.
Bookmarks