pygame-ce
pygame-ce copied to clipboard
Implement a Vector2.from_polar class creation method
Please implement the ability to create a Vector2 directly from polar coordinates.
Upstream pygame recently added this ability: https://www.pygame.org/docs/ref/math.html#pygame.math.Vector2.from_polar
Implementing this enhancement would allow for easier Vector creation without the need to create a Vector2 first then call its from_polar() method to set its parameters.
What about having from_polar return itself?
So you could do v = pygame.Vector2().from_polar((r, phi))
The upstream pygame implementation goes to pains to make sure that isn't possible, instead you would do v = pygame.Vector2.from_polar((r, phi)). I'm just not sure if there's a reason my first option above is undesirable.
What you suggest is precisely what I tried to do initially and failed. I am perfectly ok with that implementation instead assuming of course that you are ok with continued divergence from the upstream.
I'm just not sure if there's a reason my first option above is undesirable.
It would be a nice extra to also have that, but not supporting the upstream way makes the drop-in replacement idea not apply. It's one of a few paper cuts that have kept me postponing support of pygame-ce in my hobby project.