Results 1 to 4 of 4

Thread: Interpolation points of a fitted curve

  1. #1
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Interpolation points of a fitted curve

    What I wish to do: Find the intersection of the fitted curve with another curve(which happens to be a straight line.
    How:
    1. Get Curve Points
    QwtSplineCurveFitter *fit = static_cast<QwtSplineCurveFitter *>(orgnlCrv->curveFitter()); ///find curve Fitter
    int div = fit->splineSize();//find spline size of curve fitter
    QwtSplineCurveFitter fit2;//create a local curve fitter object
    fit2.setSplineSize(div); //set spline size to that of orginal curve
    fit2.setFitMode(QwtSplineCurveFitter::Spline);//specify type of fit mode

    QPolygonF crvPt, d_pt; //d_pt has data points of original curve
    populateD_pt(); //utility function which populates d_pt
    crvPt= fit2.fitCurve(d_pt);
    //

    2. Make a QList of QlineF with crvPt //crvPt[i] and crvPt{i+1], iterate i
    3.Use intersect method of QLineF with each of segments of original curve with the second curve. Find the intersection pt.

    Problem QPolygonF crvPt has integer values! The resulting intersection point is at integers on graph.

    Right now I assume linear interpolation between two data points of original curve, but the intersection point I get with this assumption is not exact obviously! It would be great if i can get the exact intersection point with the original curve.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Interpolation points of a fitted curve

    Quote Originally Posted by pkj
    Problem QPolygonF crvPt has integer values!
    Which points are the integers - the values you pass into the interpolation or those, that you get ?

    Note, that Qwt is open source. The spline interpolation is not much code and you should be able to debug and understand what is going on quite easily.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    pkj (23rd February 2011)

  4. #3
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Interpolation points of a fitted curve

    Thanks Uwe.
    Btw, the values i pass to interpolation are double values and the values i get by interpolation are integers.
    I went through QPolygonF QwtSplineCurveFitter::fitSpline( const QPolygonF &points ) const function in qwt_curve_fitter file as you suggested. There while returning the values you round it up to integers. If we use the curve fitter for very small values, it shows steps for perhaps the same reason.

    Round about method I now use:
    I scale up the values(multiply by say 1000) get the interpolation points, and scale it back...

  5. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Interpolation points of a fitted curve

    Indeed - this rounding seems to be left from Qwt4/Qt3 days, where the spline interpolation was used inside of the curve painting code only and Qt had no double based QPainter API. So rounding to integers was merged into the interpolation code for performance reasons - to avoid an additional pass.

    When the spline interpolation is used for painting only you won't notice this bug because Qwt5 and Qt internally round the values to integers anyway. But with the modified ( double based ) render engine of Qwt 6 you would see the bug, when rendering f.e. to PDF.

    Fixed in trunk and the 5.2 branch.

    Thanks for reporting,
    Uwe

Similar Threads

  1. drawing smooth curve to a set of points - without qwt
    By szisziszilvi in forum Qt Programming
    Replies: 0
    Last Post: 24th January 2011, 08:51
  2. Replies: 4
    Last Post: 6th October 2010, 13:29
  3. get the point of a fitted curve
    By giusepped in forum Qwt
    Replies: 1
    Last Post: 2nd January 2009, 04:03
  4. Get the points of a fitted curve
    By giusepped in forum Qwt
    Replies: 4
    Last Post: 25th December 2008, 07:42
  5. Replies: 5
    Last Post: 10th October 2008, 06:44

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.