QPointF::dotProduct()
-
The documentations of QPointF::dotProduct sort of suggests that this returns a value that is the lengthsquared which might be interpreted as the distance between the two points. I realise that it actually computes the matrix dot product which for the two points:
QPointF p( 3.1, 7.1);
QPointF q(-1.0, 4.1);will indeed be 26.01
However the distance between the two points is clearly:
sqrt(pow(p.x()-q.x(),2) + pow(p.y()-q.y(), 2)); Which is 5.0804.
I think it would be beneficial to update the docs to explain that you'd use the dot product for as it doesn't return distance squared!
David
-
Since when can 'dot product' interpreted as distance betwen two points?
-
@Perdrix said in QPointF::dotProduct():
so when would I want to use the dotProduct of two QPointFs?
When you need to calculate the dot product between two vectors I would guess?
-
https://code.woboq.org/qt5/qtbase/src/gui/painting/qstroker.cpp.html#507
https://code.woboq.org/qt5/qtbase/src/gui/painting/qstroker.cpp.html#569And see wikipedia link I gave you why you need a dot product of two vectors.
-
@Perdrix said in QPointF::dotProduct():
The question is why/when I would want to form the dot product of two points.
Think of a "point" as a "position vector" from the origin to that point. Does that help?
The documentations of QPointF::dotProduct sort of suggests that this returns a value that is the lengthsquared
This has been fixed in Qt 6.3 documentation: