Results 1 to 9 of 9

Thread: Get any point's Coordinates in a Curve

  1. #1
    Join Date
    Dec 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Get any point's Coordinates in a Curve

    Hello,

    I use a QwtPlotCurve with some points assign with setRawSamples. I want to get the X or Y cooridnates of a point in the curve using Y or X associated coordinate, but this point is not always a point that i use to create the curve.

    Exemple:

    i have two point to create the curve

    pointA(0,0) and pointB(2,2) and i want to find the coordinate of the point in the curve coresponding to x = 1. in this case the point has 1,1 for coordinates.

    is this is possible and how to do.
    Thanks for your help.

  2. #2
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get any point's Coordinates in a Curve

    no, that is not possible. A QwtPlotCurve has a member to find the nearest point, but it can't interpolate. You have to code such a functionality by yourself, but that should be quite easy by applying some geometrical calculations.

    hth,
    Felix

  3. #3
    Join Date
    Dec 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Get any point's Coordinates in a Curve

    Hum have you some link that explain how to calculate something like this.
    With some points we have a line and it's simple to calculate a coordinate on the line, but with a large number of points it was not so easy or i'm wrong?

    In fact my goal is to add a marker on an X coordinate and the Y coordinate move with the curve. Is it possible to do this without recalculating the Y coordinate each time? I didn't find a good way to do this without setting Y value each time. In some cases i need to find local extremum but in this cases i need to calculate this extremum but in case of interpolated curve, the extremum can not be a point use to create the curve, i'm right?

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

    Default Re: Get any point's Coordinates in a Curve

    Quote Originally Posted by Schoumi View Post
    Hum have you some link that explain how to calculate something like this.
    With some points we have a line and it's simple to calculate a coordinate on the line, but with a large number of points it was not so easy or i'm wrong?
    You are: each coordinate is between 2 curve points and this is always ( beside of splines ) a simple line. The number of curve points doesn't matter.

    Uwe

  5. #5
    Join Date
    Dec 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Get any point's Coordinates in a Curve

    hum ok, but in an interpolated curve, two points can be on each side of an extremum and obtain the extremum value could not be as easier as calculate a line equation between two point, because the result must not be on the curve, or i'm wrong again?

    Thanks for your explanation

  6. #6
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get any point's Coordinates in a Curve

    Hi schuomi,

    a QwtPlotCurve is not a "real" curve. It is a number of points that are connected by straight lines. So it is not possible that there is an extremum between two points.

    If your curve uses interpolated data, you must access the "real" data storage to obtain the underlying values.

    Felix

  7. The following user says thank you to FelixB for this useful post:

    Schoumi (7th December 2011)

  8. #7
    Join Date
    Dec 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Get any point's Coordinates in a Curve

    yep, in fact to get the extremum, i explore some points where i search for extremum and when the orientation of the curve seems change i say that the point is an extremum.

    The data must be interpolated by me or Qwt do this for me? I think that the curv was always interpolated if it was needed but if Qwt don't do this. I have the real value and i do the right thing.


    Added after 1 53 minutes:


    I don't know if i express that i want clearly.

    I want to create a plot with marker, a marker must be at an extremum or at an horizontal position on x Axis and the y position of this marker is on the curv. The curv is product by a series of data, sometimes i have lots of points some time few points. The curv will be interpolated in case of few points (if it's not the case actually, by default a curve is interpolated?)
    What i need is to set the y position of the marker if i didn't need the extremum or the two position on the extremum value.
    Qwt offer function to do that easyly? or like felixB said, i need to create function to get the y position?

    I have wrote a function that search the closest point from the marker, and from this point search the x position of my marker with two point, one before and one after. when i have the intervalle that embrace my marker position i get their y position and create the line equation to get the y position of my marker. (y =ax+b). i'm on the right way or not? And for the extremum i have wrote a function that use this function and after locate my marker search the extremum by analyse point to point value, if by using to point, one go left of the marker and one go right. if one of these points change direction (the last point saved is lower(in case of top extremum) or upper(in case of bottom extremum)) i use it as extremum and set the marker as the new position.

    Thanks for your time, this is my first projet with qwt and i don't understand sometime the logic of programming with it.
    Last edited by Schoumi; 6th December 2011 at 11:41.

  9. #8
    Join Date
    Dec 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Get any point's Coordinates in a Curve

    hum ok, with setCurveFitter, my functions don't work like I want because sample(position) return the point that i add to it and not the interpolated point, is there a way to get the interpolated points?
    My method works only on linear interpolation.


    Added after 51 minutes:


    ok, i've tried another solution and use my solution with some modification

    I use a part of the code of the first post of this topic http://www.qtcentre.org/threads/3896...a-fitted-curve with little modification to get the QPolygonF of the interpolated curve and affter i interpolated again this point to obtain all interpolated point, and after i search the line equation like i said before.

    Edit:
    Is it possible to fitCurve only one time? in this case the curve is fitted when i use setRawSample and when i want to get all interpolated points.
    Last edited by Schoumi; 6th December 2011 at 15:33.

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

    Default Re: Get any point's Coordinates in a Curve

    Quote Originally Posted by Schoumi View Post
    Is it possible to fitCurve only one time? in this case the curve is fitted when i use setRawSample and when i want to get all interpolated points.
    http://qwt.sourceforge.net/class_qwt...c2adf81e120140

    Uwe

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

    Schoumi (7th December 2011)

Similar Threads

  1. Tool tip in point of curve
    By ruzik in forum Qwt
    Replies: 4
    Last Post: 23rd October 2011, 12:23
  2. Replies: 3
    Last Post: 21st June 2011, 19:37
  3. Replies: 2
    Last Post: 28th April 2011, 08:42
  4. Replies: 1
    Last Post: 9th December 2009, 17:14
  5. get the point of a fitted curve
    By giusepped in forum Qwt
    Replies: 1
    Last Post: 2nd January 2009, 04:03

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.