2

There's a code based on QML and QWT, kind of a graph maker with additional possibilities. One of the technical requirements is to get Y coordinate of a plot curve depending on some X coordinate.

There's an inaccurate way to do it - get the QPoint of QwtPlotCurve closest sample to some X coordinate.

int sampleIndex = curve->closestPoint(plotCanvas->mapFromGlobal(event->pos()));
QPointF sample = curve->sample(sampleIndex);

The most problem is that QwtPlotCurve can provide only samples coordinates, but I need to be able to get coordinates between samples as well. For example:

[Explanation (image)]

How to get Y curve coordinate if I know any X coordinate, not only sample?

I am a Student
  • 1,570
  • 4
  • 21
  • 36
Nikita
  • 337
  • 1
  • 3
  • 12

1 Answers1

1

If you are able to determine at least two points on each lines, then there is a mathematical solution to the problem. The complete explanation is here Line–line intersection

Gianluca
  • 3,227
  • 2
  • 34
  • 35