Search code examples
drawingfractals

Drawing fractal flames


Let me start off with the link to the PDF I've been reading to kickstart me into drawing fractal flames.

http://flam3.com/flame_draves.pdf

Following Draves' pseudo code I had no trouble drawing Sierpinski's Gasket using the three provided functions:

F0(x, y) = ( x/2 , y/2 ) 
F1(x, y) = ( x+1/2 , y/2 ) 
F2(x, y) = ( x/2 , y+1/2 )

Pseudo code:

(x, y)= a random point in the bi-unit square
iterate { 
    i = a random integer from 0 to n − 1 inclusive
    (x, y) = Fi(x, y)
    plot (xf , yf ) except during the first 20 iterations
}

From what I understand, fractal flames are made by applying variations (non-affine functions), but if we look at the catalog of variations in the appendix, the first image (Variation 0) is supposedly made with the identity variation.

Now I can't wrap my head around how can an image like that have been created with using only one function, on top of which an identity function. (Wouldn't it only draw one pixel infinitely as we are applying identity function on a randomly chosen pixel?)

It's not clear to me whether I should use the same pseudo code as for Sierpinski's gasket or is there some other catch I'm not seeing here?

Edit: Here's the end product containing the fractal flames image generator written in Java: https://github.com/xtrinch/fractal_generator


Solution

  • Now I can't wrap my head around how can an image like that have been created with using only one function, on top of which an identity function. (Wouldn't it only draw one pixel infinitely as we are applying identity function on a randomly chosen pixel?)

    The variations aren't used on their own however. Rather, they are applied to the results of the i possible affine transformations. Refer the formula at the bottom of page 4 under the heading "3 Variations":

    Fi(x, y) = Vj(aix + biy + ci, dix + eiy + fi)

    If j is 0 and you are using variation 0:

    V0(x, y) = (x, y)

    then

    Fi(x, y) = (aix + biy + ci, dix + eiy + fi)

    In other words using variation 0 just means a simple affine transform with no additional variation applied to it. a, b, c, d, e, f are the affine transform parameters for Fi and you will have i sets of them.

    If j is 1 then the variation function is:

    V1(x, y) = (sin (x), sin(y))

    so

    Fi(x, y) = (sin(aix + biy + ci), sin(dix + eiy + fi))

    and so on.

    As mentioned a bit further on, for each of your i functions you can have a blending parameter vij for each variation, so you compute your affine transformation, apply all the different variation functions to the affine-transformed point and then blend the results together according to the blending factors.