A rotozoomer is also a fairly simple effect, but it needs a little math and linear algebra. Basically, what we want to do is to rotate some picture on the screen and as a little bonus, it can zoom too. It’s easiest to imagine it as the screen being rotated over the texture plane. The rotation matrix is:
We want to step independently in x and y directions, so to get the increments in each direction we represent the coordinates in the plane as and multiply the rotation matrix with single steps in each direction. Thus, the step in x is:
The step in y is:
For a little extra spice, we multiply these with a scaling factor.
The texture used is from the old Hungarian diskmag The Guide (#1) where I first read about the implementation of this effect. Of course, the increments in each direction are open to experimentation, one can probably derive much nicer effects from this. It’s also funny to see, that cpu cache problems can be observed at some angles, when the pixels on the screen are close to orthogonal to the pixels in the texture so big jumps have to be made in the memory to access each pixel. It seems that java operates at a level pretty close to the cpu.
(later edit: i used a less nsfw texture for this effect, the original can be seen after the fold)