Closed italomaia closed 10 years ago
"Unsanitized" rotation is not a problem, since functions operating on angles are usually periodic and therefore accept angles beyond the range [0:2π]. More importantly, it is also wanted, since this way you can count the number of turns by dividing by 2π. Likewise, you can also determine the direction of turns by looking at the sign of shape:rotation()
.
However, if you absolutely want to keep rotation in the range [0:2π], you can do the following:
shape:setRotation(shape:rotation() % (2*math.pi))
I just noticed polygon:rotate could make my polygon rotation number to go beyong math.py * 2 and there is no documented way to sanitize it. Messing around with _rotation, which is probably a bad idea, does the trick.
My suggestion here is to create a way to allow the developer to sanitize the rotation by himself or do it internally. Don't know if this could be a issue for other projects, but thought it would be worth mentioning.