Lab 8: The Mandelbrot Set
CS 145: Images and Imagination, Spring 2014


Due Date:
Final submission is due Friday, April 25 before class.
This lab is worth 20 points
See policy page for late penalties.

Summary of Goals

The main goals of this lab are to:

While Loops

The while-loop is a more general type of loop than the for-loop (a for-loop can always be replaced by a while-loop but not vice versa). There are actually two versions: "while" and the "do-while":

The Map Function

Read about the map function in the online Processing reference. The map function is very useful for rescaling numbers. For example, suppose you want to rescale pixel values (range 0 to 400) so that these values instead fall in the range of x= 1 to 2. (This is needed later to convert a pixel value to a value in the complex plane.) For example, what would the corresponding x value be for pixel 230? The image to the right, shows the relationship between the different map parameters. In this case, the x value would be 1.575

Program 1: Using the Map Function
float xMin = 1;
float xMax = 2;
int pixMin = 0;
int pixMax = 400;
int pix = 230;
float x = map(pix, pixMin, pixMax, xMin, xMax);
println(x);
Program output: 1.575

You will need to use the map function in the Mandelbrot program to transform a pixel in the Processing window (as defined by the width and height) to the corresponding point in the complex plane as defined by minX, maxX, minY, and maxX. The picture is shown below. Imagine these to rectangles sitting on top of one another. Given an (i,j), you want to know what the corresponding value of (c_real, c_imag). You need to apply the map function twice, once to get c_real from i and again to get c_imag from j.

Before you proceed, try writing down these two map functions. Use Program 1 as a guide.

The Mandelbrot Set

To Be Submitted

At the beginning of class on Friday, April 25: