Results 1 to 9 of 9

Thread: Get any point's Coordinates in a Curve

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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,313
    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)

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.