Efficient image rotation via sheers (maybe)

I don’t know what the current state of image rotation in Arcade is but I remember back in the day the option I was using was a pretty inefficient power-of-2 scale then sample technique and the best way to get this to go fast was to pre-generate a flip book w/ ~16 angles or so, but this used quite a bit of memory and it was annoying to set up.

Anyway I just learned about a way to efficiently rotate sprites that just uses three sheers operations and has some nice properties (no pixel duplication or loss) and might be efficient enough to be done in real time on low end hw since it used to be common practice on pre-gpu hardware:

https://www.ocf.berkeley.edu/~fricke/projects/israel/paeth/rotation_by_shearing.html

Since there’s no data loss and the operation is reversible, it might even make sense to do in-place update of the image data to save on memory.

Hopefully this is a useful data point for the next extension writer that wants to revisit rotation (if it isn’t solved already) :slight_smile:

9 Likes

This is super cool!

@eanders @jwunderl

2 Likes

YES THIS IS WHAT IVE BEEN ASKING!! yey