I'll merge this in now. Consider it stable(ish).
Hi,
here is a PR for Vector changes from our discussion here (and elsewhere).
https://github.com/pygame/pygame/pull/416
- Tests and fixes for keyword arguments with Vector2 Vector3
- Tests for Vector2, and Vector3 scalar constructors like GLSL.
Vector3(1) -> Vector3(1, 1, 1)
-
Russell Jones wrote:
IDK about physics, but AIUI, Z points from side to side, Y points down
and X points diagonally; it's Λ that points up.
Only if your computer screen is oriented vertically.
If you're using a tablet in your lap, Λ points forward
and Y points backwards.
So obviously the code
IDK about physics, but AIUI, Z points from side to side, Y points down and
X points diagonally; it's Λ that points up.
(sorry)
Russell
On 1 March 2018 at 08:43, Greg Ewing wrote:
> Daniel Pope wrote:
>
> Y points up in real physics?
>>
>
> No, no, no. Z points up
René Dudfield wrote:
So it might be nice to return the length(magnitude) there?
BTW, I don't really like the name "length" for a function
that returns the magnitude of an arbitrary vector. It only
makes sense for vectors representing a physical distance;
it's nonsense for anything else
Having normalize_ip return the old length would be a bit weird.
Yeah, another name like 'normalize_ip_return_length' But maybe longer ;)
speed = direction.length_normalize_ip()
What is UP for rock climbers hanging upside down,
when they are chatting on their phone,
which points towards the horizon,
whilst they live in Australia? ;)
( @Ian... give in to the temptation... )
Thanks Victor, those are some good notes.
And I guess some of them will take some time to
On Thu, Mar 1, 2018 at 1:43 AM, Greg Ewing
wrote:
> No, no, no. Z points up in real physics!
Oh, and I expect "j" is the imaginary unit, "Σ"s can be omitted, gravity is
exactly 10 m/s, without the square, and anyway one can drop units whenever
one feels like it?
(
Daniel Pope wrote:
Y points up in real physics?
No, no, no. Z points up in real physics!
--
Greg
> 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.
Y points up in real physics?
This is making my head hurt; I need to go lie -Y.
On Wed, 28 Feb 2018, 22:52 Victor Blomqvist,
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
> Vector2(x=0, y=0) -> Vector(0, 0)
If rgba and uvst are swizzle attributes, are they also accepted as kwargs?
> However, I feel this single scalar is hard to make
a mistake with accidentally passing in the wrong thing?
I don't think so. I think it could easily happen accidentally, while
> We want to go two left? This is sort of nice.
> >>> velocity + Vector3.left * 2
Christening a particular axis or Vector as "left" had all kinds of
problems. Which way is up? +y, like a graph? -y, like Surface coordinates?
Is it a left-handed or right-handed coordinate system?
On Tue, 27 Feb
(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
Some static constructors could be useful.
up, down, left, right
forward, back
zero, one, two, ...
>>> velocity = Vector3(1, 2, 3)
We want to go two left? This is sort of nice.
>>> velocity + Vector3.left * 2
>>> Vector3.left
>>> Vector3.right
Some good points. Thanks, I appreciate the discussion.
On Tue, Feb 27, 2018 at 3:51 PM, Daniel Pope wrote:
> > Single scalar constructor should Vector2(1) == Vector2(1, 1)
>
> This is the kind of situation where I'd follow PEP20: "In the face of
> ambiguity, refuse the
> Single scalar constructor should Vector2(1) == Vector2(1, 1)
This is the kind of situation where I'd follow PEP20: "In the face of
ambiguity, refuse the temptation to guess." There's an obvious pitfall if
you expected to pass a tuple and you instead pass a scalar or the wrong
length tuple - it
I've done a much larger review and testing.
Comparing it to different vector implementations,
and looking at how it inter-operates with pygame and OpenGL APIs.
TLDR; these things need to be fixed:
- scalar construction is buggy.
- One naming improvement I'd like help with is .elementwise() ? I
I won't move pygame.math.Vector2/3 into pygame or pygame.locals namespace
for now.
That's potentially breaking things which already have their own Vector2/3.
This type of API change will wait for pygame 2.
Narrative documentation is missing, and I'm working on that now.
I fixed a bunch of compiler warnings, added a test for lerp(), and tweaked
the documentation.
Note that the pickle stuff isn't working under pypy.
Indeed, getting the attribute returns a float so the attribute should be
settable as a float for consistency.
If users are familiar with GLSL[1], they might be surprised that the type
of vectors returned by swizzle attribute access is not a vector:
>>> from pygame.math import Vector3,
Hi,
that's a good point.
TLDR; I think it should be on by default too. There's still a couple of
issues with doing that.
It should have _no_ cost in almost all cases for attribute access. Because
it first tries normal attribute access.
See:
Does the Swizzling have a cost if you're not using it? If not I'd be
tempted to say it should always be on.
On Sat, 24 Feb 2018, 18:00 René Dudfield, wrote:
> Hey hey,
>
> I noticed the pygame.math vectors couldn't be pickled/unpickled.
>
> So that has been added here:
>
23 matches
Mail list logo