Inconsistency between QLineF::angle and QTransform::rotate

  • Does anyone know if there's a special reason for the inconsistency between QLineF::angle and QTransform::rotate?

    The former defines zero degrees at "the 3 o'clock position".

    The latter does not define the zero degree position at all (as far as 4.7 docs are concerned), but appears to use the 12 o'clock position for that.

    My guess: Two developer teams that didn't talk to each other.

  • Moderators

    The difference is not just limited to Qt routines. It depends on the definition of your coordinate system (left-handed or right-handed).
    For QLineF apparently the definition of mathematians is used. Horizontal x- and vertical y-axis. The angle is defined starting at x-axis going to y-axis (right-handed system).
    In mapping typically a left-handed system is used. x is vertical pointing towards North and y is pointing to the East (right). The angle is again defined to start at x-axis and increasing towards y-axis.
    Transformation are typically associated with maps.

  • I know there are different ways to define the coordinate system. It doesn't really provide a good argument to mix different ways in the same API, in my opinion.

    The thing that irritates me most is that the behaviour isn't even documented in QTransform::rotate, as if that was the only way to do it.

  • Moderators

    About the documentation you are certainly right. It should be properly documented. You might want to file a report on "JIRA": .

    However, one has to be careful with adjusting the definition. One has to stay within the common rules used in mathematics and cartography. Otherwise it will end in a mess.

    BTW I have not checked, if the current definition is conform with these common rules.

  • Moderators

    Should have checked prior to writing an answer :-(

    "under": you find this text.

    Rotates the coordinate system counterclockwise by the given angle about the specified axis and returns a reference to the matrix.
    Note that if you apply a QTransform to a point defined in widget coordinates, the direction of the rotation will be clockwise because the y-axis points downwards.
    The angle is specified in degrees.

    Which means that the rotation starts at 3 o'clock, but this definition is really ackward for maps.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.