Hi,

René sent an email asking if I had any input (as the author of pymunk), so
here I am. In general I think it seems like a very well versed vector
library in the making :)

A couple of comments:
1. A function that normalizes and returns the length before normalizing in
one call can be useful and be a little bit faster than doing two calls. In
the pymunk.vec2d class its called normalize_return_length.

2. A user asked me why a vector cant be scaled up again after it has been
scaled down to 0 (which is not supported in the pymunk.vec2d class or
pygame.math). It would be a very useful feature and also beginner friendly.
However, I dont see a way to do it in a good way so I havent implemented
anything.

3. As René pointed out in most of the Pymunk examples Y is converted so
that positive Y points up to keep examples consistent and close to "real"
physics. Would be nice if pygame could handle it easily, maybe something
you could set in the beginning of you code? But Im not sure if it fits here
:)

4. In many cases Pygame methods expect an integer, such as position in
pygame.draw.circle(). Since Vector2 seems to be a float either some
automatic rounding or a method Vector2.int_tuple or similar would be
convenient?

5. You already do some benchmarking, did you try Pypy?

/Victor



On Tue, Feb 27, 2018 at 10:55 PM, Ian Mallett <i...@geometrian.com> wrote:

> ​(Skims discussion)
>
> For e.g. `abs(Vector2(2,-1).elementwise())`, my (C++) library instead
> handles this as `abs(Vec2(2,-1))`, returning another `Vec2`. In C++, if you
> weren't expecting that, you get a compile error on whatever happens next,
> whereas in Python you'll get a `TypeError`, so it's well-defined.
>
> If you want the vector's length, I use a function, but perhaps it's more
> pythonic to use a method: `Vec2(2,-1).getLength()`, or
> `Vec2(2,-1).getLengthSq()`.
>
> If your vector represents a complex number and you're wondering why
> `abs(...)` shouldn't return a complex modulus, then I ask why you aren't
> using the built-in `complex`, which is designed for this.
>
> Ian
>

Reply via email to