#rotations in numpy for vectorio
1 messages · Page 1 of 1 (latest)
summary: the rotation calculation drops from 8ms to 0ms per iteration, but converting the ndarray to the list of tuples that vectorio wants as input adds 28ms per iteration!
an ironic thing is that i just looked at the vectorio implementation, and it internally represents the polygon as a flat array of int16_t! so the really inefficient round trip through a list of tuples is unnecessarily strict type-checking
Oh thank you! That seems to match my experiments with ulab too: actual dot product was fast but marshaling into/out of ndarray was slow
My goal is to create a vector style 1980s game like Tempest where the game elements smoothly rotate & scale. Was hoping to use vectorio for that and I maybe still can but will have to simplify objects
i think relaxing the vectorio implementation might give you the best results. like maybe have it take any iterable or array that gives you the right numbers?
commented on your gist with my code
Thank you! That was really helpful. I had gotten myself confused with NumPy data structures and what you did was much cleaner than what I was hacking my way through
it was admittedly a bit tricky, because i had to transpose the representations of everything so that i could minimize transpose operations in code
i think the list and tuple creation are a lot more expensive than the float to int conversion (which is not trivial, but not that expensive either; i think i did the comparison, but didn't leave the code for that)
my intuition is that it will make a much bigger difference if vectorio can take any appropriate iterable instead of strictly type checking for a list of tuples
you mean having vectorio can take ulab ndarrays?