V-variable Fractals

V-variable Fractals

In the context of an assignment for a course Random graphs and Fractals, I wrote a report on V-variable fractals and created a computer program to generate such fractals in three dimensions.

Report

The report is mainly a summary of the theory presented in the articles A fractal value random iteration algorithm and fractal hierarchy (arXiv link, PDF) and V-variable fractals and superfractals (arXiv link, PDF), both by Barsnley, Hutchinson and Stenflo, but it also adds a few comments in footnotes and a section discussing computer implementation. In particular, it briefly discusses methods suitable for generating three-dimensional fractal graphics, using standards such as OpenGL or Direct3D. A few images, generated by my program, demonstrate the beauty of such fractals.

You can read my report in PDF (2.8 MB) format.

Computer program

The computer program for generating V-variable fractals uses the OpenGL standard to interface with modern PC hardware support for displaying three-dimensional graphics. It allows the user to define custom IFSs (Iterated Function Systems) to generate V-variable fractals, and some examples are already included. The IFSs can be iterated step by step, and the steps can be animated. Defined transformations, IFSs and superIFSs are saved in a file.

The program was written using Lazarus, an open-source Delphi replacement. Instead of using the OpenGL API directly, it uses an object-oriented wrapper library called GLScene. (It could be easily adapted, though, to use OpenGL API calls.)

You can download the program and its source code here from the download page.

User guide

Getting started

To get started with the computer program, download the Windows binaries, extract the files to a directory and run the vvfgenerator.exe program. You'll see two windows: a main window, and a tool window called 'Object Editor'. The main window has a number of controls on the left. Select the 'Sierpinski' item from the list of 'V-Vraiable Fractals/SuperIFSs'. Now click the 'Init' button below the list; a triangle appears in the render area on the right. Actually, this is a not a triangle, but a tetraeder. To see this, rotate the scene by dragging your mouse while holding the right mouse button. To move the center of the scene, drag your mouse while holding the left mouse button, and to zoom hold both mouse buttons or use the scroll wheel.

Once you have a nice view of the tetraeder, click the 'Step' (next to the 'Init' button) to perform one iteration of the forward process of the superIFS. You can repeat this as many times as you like, but be careful: at each iteration, the fractal becomes more complex and the time required to render the scene, will increase exponentially. The number of iteration steps you can perform without effectively locking up the program depends on your computer hardware.

Animation Control

Now select another fractal, 'PythagorasTree', and click 'Init'. A triangle appears again. Click 'Step' and adjust the view as desired. As you probably noticed, the iteration steps are animated. The animation is controlled from the 'Animation Control' on the left. The slider allows you to manually control the animation; it will advance automatically whenever the 'Animate' option is checked. The drop-down box allows you to choose between three animation modes:

  • amLast: the transformations the 'largest' level are animated (these are the transformation applied last to the buffers)
  • amFirst: the transformations at the 'smallest' level are animated (these are the transformation applied first to the initial buffers)
  • amAll: all transformations (at all levels) are animated simultaneously

To get a feeling for what the difference between these three modes is, just try them.

Sticky mode

Another control on the left is the 'Sticky Control'. It allows you merge all previous iterations in one picture. There are three sticky modes:

  • smNone: don't show the previous iterations at all
  • smIdentity: show the previous iterations in-place
  • smMove: show the previous iterations, all next to each other, using the value next to it as distance
The smIdentity mode is very useful for fractals such as the PythagorasTree. Technically, you could also add an identity transformation to the IFS, but the Sticky Control is just a quick way to show or hide previous iterations, as well as to show them next to each other.

V-variable Fractals

The 'SierpinskiMixed' and 'PythagorasTreeMixed' fractals are examples of V-variable fractals. They use more than one IFS, and more than one buffer. Each initial buffer is given a different color, so you can distinguish between them. The 'Buffer Distance' item at the bottom left allows you to set the distance between the buffers in the rendered scene.

The first iterations of a 5-variable Sierpinski fractal, using contractions with factor 1/2 and 1/3. This is a 3-dimensional version of the example given in Figure 3 of the article V-variable fractals and superfractals that is mentioned above (PDF).

Custom IFSs

You can also create custom transformations, IFSs and superIFSs (called VVariableFractals in the program). This is done using the 'Object Editor' tool window. This window has three sections. The upper section represents a class tree of the objects that can be edited. (Each class name starts with a capital T by convention.) Depending on which class is selected, the second section shows all created objects that are of that class type. The last section allows you to edit the properties of the selected object.

The names of the properties should be mostly self-explanatory. All objects have a Name property, which should be a valid identifier (consist of alphanumerical characters, no leading digit) and unique. Some properties are list-valued; when you click on the text 'n items', a button with '...' appears. Click it to bring up the list editor. The list contains items that are in fact references to other objects. So you have to create these objects first.

To create a new object, right-click the desired class in the class tree and choose 'Add Instance'. To delete an object, right-click it in the object list and select 'Remove Instance'. Note that you can save your changes by clicking 'File', then 'Save' in the menu of the main window.

The object hierarchy is as follows:

  • A TVVariableFractal contains one or more TIFSs.
  • A TIFS contains one or more TTransformations.
  • One of the TTransformation types, TCompoundTransformation, contains TTransformations again.

The program is ready for adding different buffer and IFS selection mechanisms through the abstract TSelector class. Currently, there is only one descendent class implemented: TIIDUniformSelector. The TIIDWeightedSelector class is already there, but it is not operational. You can use the UniformIID object for the BufferSelector and IFSSelector properties of TVVariableFractal objects.

The program could also be adapted to use different representations of the buffers. The abstract TBufferFactory class has currently one descendant class: T3DGLSceneBufferFactory, which uses GLScene components to represent a 3-dimensional buffer. You can use the Default3DGLSceneBufFactory object for the BufferFactory property of TVVariableFractal objects.

Compiling

If you want to compile the program yourself, you'll need