[Development] FP calculations and stability in Qt

Christian Gagneraud chgans at gmail.com
Sun May 12 12:49:20 CEST 2019


On Sun, 12 May 2019 at 20:26, Konstantin Shegunov <kshegunov at gmail.com> wrote:
>
> Hi,
> I'd want to clear the context out of the way, so this is the bug[1] that got me thinking.
> I appreciate that we want to keep external dependencies to a minimum, and for a good reason, but can we talk about how feasible it is to pull something (or parts of it) in Qt, even if only internally, to facilitate stable fp calculation.
>
> I've seen some complaints (on the forums mostly) about the stability of the transformations Qt supplies, generally unfounded, however it'd be nice if we can solve this with generality. I realize Qt is no math library and support the idea to drop most of the global functions that dealt with math, in the end they're already in the STL. However, as it is, we have some linear algebra done (internally mostly), so I think it'd be nice to have that done "correctly" for the user.
>

I use to think that Qt could do a better job about FP
precision/stability, but i had to realise that i was using Qt in a way
that it was not designed for.
For example, I tried to use QPainterPath, QLineF, QRectF, ... to do
geometry processing. And i can tell you that QPainterPath is all but
stable when it comes to small values. Highly zoomed-in QGraphicsView
based geometry object yields crazy artifacts.
I then turned on specialised library, Qt is a GUI toolkit, and is
optimised for painting. Qt takes all opportunities to be fast and
efficient in that context, and that includes being "mathematically"
imprecised, painting is all about pixels at the end of the day.
Who cares where exactly a line intersect a polygon, if all you need to
know is if you need to paint a pixel black or red.

To summarise:
I ended up using "proper" geometry processing library for the "model"
and used Qt to do the rendering (the view).
It came at a cost, but in the long term was a big win.

Chris

> I'd appreciate feelings and opinions on the matter, as I'm but one person and my view is rather limited.
>
> [1]: https://bugreports.qt.io/browse/QTBUG-75146
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development



More information about the Development mailing list