Correct interface should be
qreal qAtan2 ( qreal y, qreal x )
This reflects the correct use of std::atan(y,x) and is in accordance with mathematics. But note that the gui coordinate system is NOT in accordance with the usual rhs mathematical coordinate system.
-Make sure you follow through parameters all the way through when fixing this. First parameter of qAtan2 should be first param of std::atan2. It does so today, but parameter names are misleading..
Documentation does not make sense. A direction is not returned, only an angle. A good explanation can be found at
The OvenTimer example attemts to use this function (for some reason the std::atan(y,x) is used) and fails badly.
Also, an issue comes into play at the typical gui coordinate system has y positive downwards and not upwards, whilst x positive to the right as is usual. In a sense comparing this to the mathematically normal y positive upwards, is like comparing a left handed to a right handed coordinate system. This can be confusing and easily causes errors in code; typically using aTan2(-y,x) instead of aTan2(y,x) fixes this. I rewrote the OvenTimer that shows a correct use of aTan2. The angle returned is in accordance with above webpage, and hence implicitly gives a 360 degree direction.
void OvenTimer::mouseMoveEvent(QMouseEvent *event)
QPointF point = event->pos() - rect().center();
// original: double theta = std::atan2(-point.x(), -point.y()) * 180.0 / M_PI;
theta_raw = qAtan2(-point.y(), point.x()) * 180.0 / M_PI;
this->setWindowTitle(QObject::tr("theta,x,y, %1 x%2 y%3")
Send me an email if I can be of assistance..
|For Gerrit Dashboard: QTBUG-27090|
|34004,2||Fix the name of the arguments of qAtan2 to match std::atan2||master||qt/qtbase||Status: MERGED||+2||0|
|76273,1||Fix the name of the arguments of qAtan2 to match std::atan2||4.8||qt/qt||Status: MERGED||+2||0|