Skip to content

Three Shears Rotation

Tristan Grimmer edited this page Aug 20, 2023 · 1 revision

This is another rotation mode I'd like to support in tacent View. Not too much to see here other than a link to the very fast and simple method for performing image rotation. What's not mentioned in the page that I think is important is that colours are preserved. The current method of colour-presevring arbitrary rotation in Tacent View involves not using any fancy filters -- basically using simple nearest-neighbour for the rotation source pixel after rotation. The skew/shear method should give better results and be faster to boot. Great for pixel art.

Data Genetics Rotation

I'm also saving this locally just in case it ever goes away on me ;) Everything below (both images and the italic text) is from Nick Berry / Data Genetics!

The heart of this method is the expansion of the single 2D rotation matrix into a three different matrices:

image

There are some very interesting properties of these three matrices: The three matrices are all shear matrices. The first and the last matrices are the same. The determinant of each matrix is 1.0 (each stage is conformal and keeps the area the same).

As the shear happens in just one plane at time, and each stage is conformal in area, no aliasing gaps appear in any stage.

In times-past, when floating point and trig calculations were expensive, these properties were very important. Because only one plane was being modified at once, no additional memory was needed as the code could simple walk down the raster line making the changes it needed. Pretty cool.

Let's see this is action:

image

In the first shear operation, raster columns are simply shifted up and down relative to each other. The shearing is symmetric around the center of the image. It's analogous to shearing a deck of playing cards. The second shear operation does a similar thing on the previous image, but this time does the shearing left to right. The final shear is the same as the first operation; this time applied to the intermediate image. No gaps! How elegant is that? We just rotated an image an arbitrary amount (smoothly) using three shear operations!

Clone this wiki locally