c++algorithmqtmathspline

Spline in QT with QPainterPath through just control points


I have to implement a spline drawing in qt based on data from a dxf file. Data about the spline always contains only coordinates of control points.

A QPainterPath function cubicTo() uses a current point, an end point (this one belongs to a spline) and 2 control points. When I want to build a spline through 5 or more control points using several cubic Bezier splines, I don't know coordinates of fit point (that belongs to the spline) between them to use cubicTo(). Also I'm not sure that an image of the spline will be correct if I'll just combine several cubic splines after calculating a missing fit point on my original spline.

What algorithm can I use to build a spline through more than 4 control points in qt, with information only about control points, not fit points?

For example, after parsing my dxf I get coordinates of control points marked as red: enter image description here At the first, I was expecting these control points are control points of Bezier curve. I have tried even to calculate them, but amount of control points for Bezier curve is more than 6 in this case. I was using an algorithm from this question. So I understand how to calculate control points, knowing fit points, but how to do it in a reverse with kind of points I get from dxf. If you'll try to use an calculation algorithm from a question for the spline like on an image, you'll get more than 6 control points, so it's some other way to characterize it.

Here is an image to show the difference between data got from this algorithm and data I have: enter image description here What math do I need to solve this and how to get mathematical description of these points? Thanks for any help.


Solution

  • Maybe, my answer is still actual, so I found good working example here.
    It uses De Boor's algorithm for getting linear interpolation points with custom step, so I can avoid using cubicTo() method and draw spline as polyline through output interpolation points.