Algorithms

IFS: Random Point Method

The Random Point Method is the most commonly used method for generating fractals using IFS iteration. IFS fractals are generated by repeatedly applying transformations to some figure. In order to store transformations, we have to store four values: rotation, dilation, x movement, and y movement. We can simply store these values in four different arrays. The Random Point Method is based on randomly choosing sequences of transformations. It turns out that we do not have to apply transformations to the original figure, but can get accurate pictures by applying them to one of the figure’s corners. That gets rid of many problems, because all we have to store about the current figure is two coordinates. The algorithm below applies the Random Point Method to generate any IFS fractal.

Constants used:

number_of_points: each one takes some time, but the more the better
num_of_iterations: the more the better, but takes a lot longer
num_of_transformations: number of transformations used to create your fractal
x_move, y_move: array containing translation values for every transformation
rotate: array containing rotation angle for every transformation
dilate: array containing dilation value for every transformation
number_of_colors: number of colors available in the computer language you’re using

```‘ repeat the algorithm for every point in the fractal
FOR num = 1 to number_of_points
‘ initialize the angle, coordinates, and scale
angle = 0
x = 0: y = 0
scale = 1
‘ do the sequence of random transformations
FOR c = 1 to num_of_iterations
trans = FIX(RND *  num_of_transformations)
‘ move along the x-axis
x = x + x_move(trans) * COS(angle)
y = y + x_move(trans) * SIN(angle)
‘ move along the y-axis
x = x + y_move(trans) * COS(angle + 90)
y = y + y_move(trans) * SIN(angle + 90)
‘ apply rotation
angle = angle + rotate(trans)
‘ apply dilation
scale = scale * dilate(trans)
NEXT c
‘ plot the point with random color
PSET (x, y), FIX(RND * number_of_colors)
NEXT num```