Omega Red

Omega Red's garbage heap

Information wants to be free.



Afinic transformations

OK... Now something for those more inclined. What are this transformations? Nothing very special: composition of translation, scaling and rotation. Some formulas (P-original point, P'- point after transformation):

  • Translation with vector [dx,dy]:
    P'x = Px + dx, P'y = Py + dy

  • Scaling with [xs, ys] coefficients (REMARK: xs and ys must be <1, without this the transformation will not be contracting!):
    P'x = Px * xs, P'y = Py * ys

  • Rotation of axes Ox and Oy with angles ax and ay (in radians):
    P'x = cos(ax)*Px - sin(ay)*Py, P'y = sin(ax)*Px + cos(ay)*Py

Every IFS fractal is an attractor of some transformation system; that is, it appears after infinite number of steps of these transformations applied to ANY starting image. The attractor itself does not change under these transformations - it's a stable "point".

Transforming of every image pixel with above formulas may take some time (especially trigonometrical functions are costly). Here comes handy the fact, that composition of our three operations affecting the pixel can be represented in more simple way. If we have transformation composed of scaling with factors [sx, sy], rotation of axes with [rotx, roty] radians and translation with vector [dx, dy] (order of the operations is important!) - then we can calculate four derived parameters:
a = sx*cos(rotx)
b =-sy*sin(roty)
c = sx*sin(rotx)
d = sy*cos(roty)

Now the formulas for transformed point's coordinates look like
P'x = a*Px + b*Py + dx
P'y = c*Px + d*Py + dy

Voila! Now we have only multiplication and addition!...

However, with large resolutions our program may be slow anyway. There is another trick that can help us do the work. Let's select one pixel, it will be our starting point. Now we randomly select one of the transformations, apply it to our pixel, draw the resulting point, and this point is our next starting point. And so on... Next point is created by applying randomly selected transformation to the previous one. (Now the similarity to the "chaos game" should be clearly seen...)

The important thing is how we select probabilities for particular transformations. Simplest way is to make them equal, but this can often lead to irregular point distribution. Better method is as follows (assume we have N transformations with coefficients a[i], b[i], c[i], d[i], i=1..N). Firstly, we calculate sum of the determinants of all transformations:
S = (a[1]*d[1]-b[1]*c[1]) + (a[2]*d[2]-b[2]*c[2]) +...+ (a[N]*d[N]-b[N]*c[N]).

Now the formula for probability of transformation number i is:
p[i] = (a[i]*d[i]-b[i]*c[i]) / S.

Yeah... Afther this dose of theory you can write your own programs that draw IFS fractals. When in doubt, experiment or contact me.


  1. "Fractals for the clasroom". Collective work, two volumes. The Bible of fractals. here you can find almost anything.


Copyright by Omega Red 2003,2004