math.Vector2.rotate fails on certain inputs

Issue #214 closed
donLorenzo created an issue

This was reported on the mailing list by Pavel Shvets:

Hello, i've got a bug in Pygame code and the error message tells me to report it here :)


import pygame

vector = pygame.math.Vector2(0, 1)
angle = 0

    while True:
        angle += 1.2
except Exception as e:
    print "%.20f" % angle
    print e


Please report this bug in vector2_rotate_helper to the developers at


win7 64, python32 2.7.8, pygame-1.9.2a0.win32-py2.7.msi

Next call produces the same error:

pygame.math.Vector2(0, 1).rotate(359.99999999999801048034)

Comments (4)

  1. donLorenzo reporter


    cause of the bug: in the code the angle is first wrapped to the interval [0,360) then rotation around 0, 90, 180 and 270 degrees have been special cased with a tolerance of Vector2().epsilon. The case were the angle is 360-epsilon was not correctly considered and triggered this bug.

  2. Log in to comment