The Simple Math Behind Image Rotation
Featuring an old-school game-development algorithm!
I recently started learning videogame development and stumbled upon the topic of sprite animation. As I was goofing around with pixel-based (raster) image rotations, I wondered how the earliest game developers tackled this problem.
Thankfully, we have a time machine (the internet) that lets us travel back and find out exactly that. One thing led to another, and I gathered enough information and made plenty of sketches to explore the mathematics behind image rotation in this essay.
If you are the type who is curious about the technical side of animation or are just someone who enjoys math, this essay is right up your alley. I will keep it beginner-friendly; I promise! Why don’t we start by figuring out what the title image is all about?
The Pixel Salad
Most digital images that we see today, be it on our phones, televisions, or monitors, are pixel-based images (formally known as raster graphics). They approximate objects and scenes that make sense to our brains using a rectangular grid, whose dimensions we refer to as resolution.
We call each rectangular geometrical element in this grid a pixel, and each pixel carries exactly one colour value (a combination of…