Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-27090

qreal qAtan2 ( qreal x, qreal y ) has wrong interface, wrong user documentation and erroneous user example OwenTimer.



    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Duplicate
    • Affects Version/s: 4.8.2, 5.0.0 Beta 1
    • Fix Version/s: 5.0.0 RC 1
    • Component/s: Core: Other
    • Labels:
    • Commits:


      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
        # Subject Branch Project Status CR V



            • Assignee:
              thiago Thiago Macieira
              ogjoeen Ole Johnny Gjøen
            • Votes:
              0 Vote for this issue
              4 Start watching this issue


              • Created:

                Gerrit Reviews

                There are no open Gerrit changes