Rotation in Three Skews

Early bit-mapped graphics such as that in Smalltalk-80 could move but not rotate images. A colleague from Carlton University mentioned to me that arbitrary rotation could be achieved with three skew operations. With only this hint I figured out how.

Dan Ingals had written about a hierarchal application of BitBlt that would perform quadrant rotations. I set out to do the same for arbitrary rotation.

Horizontal skew of a rectangle.

I coded a skew operation that would take a real number of pixel shifts per raster. This was rounded and a 1xN BitBlit composed to perform the elementary operation.

When I considered how pixels would migrate during a rotation I guessed that I would decompose the rotate into both horizontal and vertical shifts, two of one, one of the other. By symmetry I reasoned that it didn't matter which axis was shifted twice.

I coded a rotate operation that took two parameters, one for horizontal shift, the other for vertical. The last shift was the first horizontal shift applied in reverse.

I selected a suitable image and started rotating. I connected a fast loop to the mouse coordinates, x for the first parameter, y for the second. Some mouse positions were reasonable rotations, most weren't.

I explored the behavior of my wildly skewing image. Every time I achieved a reasonable rotation I marked the mouse position on my screen with a dry-erase marker. After ten or fifteen trials a sine wave appeared on my screen in orange marker.

This made a lot of sense to me. Of course motion around the circle would involve sines and cosines. I wrote a version of rotate that took one parameter, degrees of rotation and tweaked sine and cosine formulas until only unskewed rotations were achieved.