I noticed this while using Qt, going through the code examples.
When they try to set the range for the variable that stores angle (angle in this case), why does it need to be 360 multiplied by 16, instead of just 360?
the code (from the hellogl example) is
static void qNormalizeAngle(int &angle)
{
while (angle < 0)
angle += 360 * 16;
while (angle > 360 * 16)
angle -= 360 * 16;
}
another example from the colloidingmice example:
Mouse::Mouse()
: angle(0), speed(0), mouseEyeDirection(0),
color(qrand() % 256, qrand() % 256, qrand() % 256)
{
setRotation(qrand() % (360 * 16));
}
Admitting I have almost nil experi开发者_如何学编程ence in both Qt and Graphics programming, also tell if this is common everywhere or in Qt only.
Buried in this article:
The values are multiplied by 16 because QPainter expresses angles as sixteenths of a degree.
精彩评论