Why recursive data structures?
Apparently, every computer science problem has easy to understand solution that’s easy to implement but awfully slow in practice.<p>This is one of them.<p>Rotating images that way isn’t CPU bound problem. It’s RAM bandwidth and RAM latency bound problem. The optimal data structure for that is not recursive, it’s 2D array of small square blocks of pixels. If pixels are bits, I’d bet on either 8x8 or 16x16 blocks. If they are RGB, one good format for those images, optimized for rotations, is BC7 <a href="https://www.opengl.org/registry/specs/ARB/texture_compression_bptc.txt" rel="nofollow">https://www.opengl.org/registry/specs/ARB/texture_compressio...</a> the decompressor being implemented right in the graphics hardware.<p>> If we were writing an image manipulation application, we’d provide much snappier behaviour using coloured quadtrees to represent images on screen.<p>That statement was true 30 years ago, no longer a case. Branch misprediction is expensive, memory latency is huge, RAM is a block device now (the block size typically being 16 bytes for dual-channel DDR). In addition, some displays now show 8+ megapixels, and most show 16M colors.<p>For an image manipulation application, that recursive thing ain’t good at all.