[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] State of the math branch



Hi List,

I just wanted to give you a short summery of the development in the math branch.
The goal of the math branch is the inclusion of several math related types 
like vectors, matrices and quaternions.

Right now I consider the implementation of vectors in 2 and 3 dimensions as 
feature complete.
What this means is that I can't think of more functionality that I want to 
implement and all methods pass their unit tests.
I encourage everyone interested to take a look and make suggestions if they 
find functionality missing.

The current version is not written for maximum performance. 
For example Vector2 and Vector3 share many functions so no dimension specific 
optimizations are implemented. So the current implementation should be 
considered a baseline for future optimizations. 
To gauge future improvements I intend to write a rudimentary performance 
benchmark.

I don't consider the API to be set in stone. Especially concerning 
mutability. Currently vectors are mutable. 
If however it turns out that there is no significant performance hit in 
making them immutable I tend to do so.
Obviously this will only happen once I have some performance results.

After that Matrices will be up next.


thanks for your time and suggestions.

//Lorenz


PS: I feel that I should briefly comment on the slerp() method.
    I did not follow the default implementation that seems to be prevalent on 
    the Internet. There you repeatedly call the slerp method with a varying 
    parameter t. I felt this is unpythonic. In my implementation you pass the
    number of steps you want into the method which then returns an iterator
    yielding the interpolating vectors. Same applies to the lerp() method. 
    Also the algorithm for slerp() is a bit different as to support 
    interpolation to a vector of different length.