pygame-ce icon indicating copy to clipboard operation
pygame-ce copied to clipboard

Implement a Vector2.from_polar class creation method

Open bigwhoopgames opened this issue 2 years ago • 3 comments
trafficstars

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.

bigwhoopgames avatar Apr 30 '23 07:04 bigwhoopgames

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.

Starbuck5 avatar May 01 '23 07:05 Starbuck5

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.

bigwhoopgames avatar May 01 '23 07:05 bigwhoopgames

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.

devdanzin avatar Jun 23 '23 17:06 devdanzin