Part 0:  preparation  

  • Do all of the loop and function exercises.

  • Copy the following files from ftp://ftp.cs.princeton.edu/pub/cs126/mandel to an empty directory.

  • Here's a high-level view of the organization of your program.
    #include <stdio.h>
    
    /*********************************************************************
     *  Computes Mandelbrot iterates (r, s) associated with input (x, y).
     *  Returns number of iterations until r^2 + s^2 >= 4 or 255,
     *  whichever comes first.
     *********************************************************************/
    int mandel(double x, double y) {
       // do Mandelbrot iterations
    }
    
    /*********************************************************************
     *  Reads in n, xmin, ymin, width, height from stdin.
     *  Outputs turtle graphics image of Mandelbrot set in grayscale.
     *  Zooms in on Mandelbrot set and plots an n x n grid of points.
     *********************************************************************/
    int main(void) {
       // read input values
    
       // for each point (x, y) to be plotted (use nested for loops)
       //     - call mandel(x, y) function to calculate # iterations
       //     - compute grayscale value
       //     - scale point to fit in 512 x 512 box
       //     - print turtle graphics command via printf()
    
       return 0;
    }
    

  • Part 1:   Mandelbrot function

    #

    0

    1

    2

    3

    4

    5

    6

     r 

     0.125000

    -0.421875

    -0.575928

     0.455010

    -0.303564

    -1.959975

     3.945239

    s

     0.750000

     0.937500

    -0.041016

     0.797244

     1.475509

    -0.145822

     1.321613


    Part 2:   Gray-scale image


    Part 3:  Color image

    In this part, you will create a glorious color image of the Mandelbrot set.



    Kevin Wayne