Let’s begin with a simple kaleidoscope, where a pixel at coordinates z=x+iy has the original colors of an input image at the mapped coordinates Z(z)=X(x,y)+iY(x,y). It has some symmetry s. It is a mapping of the plane that does not change the output image as Z(s(z))=Z(z). Now, we want to add an n-fold color-symmetry to this symmetry. We have n different ways k=1…n to transform the color of the input image – such as leaving it as it is or making its negative for a 2-color symmetry. Each possibility will appear as often as the other ones.
How do we do that? Reading “Creating Symmetry” of Farris, we discover that we need another mapping W(z)=U(x,y)+iV(x,y) to select the good color transformation for the output image points z. In the W-plane we make n equal seized sectors around the center and the sector containing the point W(z) determines the applicable transformation of the color. More precisely, first we get the angle φ of the point (U,V) in polar coordinates. If 2π(k-1)/n < φ < 2πk/n, then we use the color transformation with number k for the output pixel at (x,y).
To get the correct switching between color variants we impose on the mapping W(s(z))=exp(2πi/n)W(z). This partially defines W(z) and makes sure that the symmetric point s(z) will in the next color sector. That is, if the color transition number k applies to the pixel at position z then the transformation number k+1 should apply the pixel at s(z).
A p-fold symmetry of the kaleidoscopic image gives back a point z if we apply it p-times on z:
We can combine the symmetry s with an n-fold color symmetry if p is an integer multiple of n, p=m*n. Then, going through a full cycle of all unique powers 0,1,2,… p-1 of s we get each color variant m times. Thus we make m cycles in the W-plane.
A good example is the p-fold rotational symmetry of rosettes. Using polar coordinates z=r*exp(iφ) we write W(z) similarly as Z(z) in the earlier post “How to generate rosettes“:
The terms with l>0 are not required, but offer additional artistic possibilities. For programming we better use real valued functions and coordinate pairs:
where the integers k and l can be negative. Note that U(x,y) and V(x,y) use the same coefficients u and v and that they are not independent. These equations resemble in part a rotation matrix.