Fractals!

From Huben's Wiki
Jump to: navigation, search

Mandelbrot.jpg

Many sorts of fractals require complex numbers to calculate. The above Mandelbrot function, for example. Today's exercise is to build enough of a complex class to run a fractal browser. You will only need to write about 7 methods.

Complex numbers have real and imaginary parts, which you should represent as double fields in your class. You should be able to remember how to add and multiply them from Algebra and Precalc: if not, ask for help.

package fractal;

public class Complex
{
// three constructors needed: 
//    no arguments
//    one Complex argument (copy constructor)
//    two arguments (real and imaginary values)
// you will also need two accessors
// you will need to be able to multiply and add complex numbers
}
  • DO NOT CHANGE ANY OF THE DOWNLOADED CODE! It is correct.
  • Look at the error messages as you try to compile: they tell you which methods are missing from your Complex class.
  • Add the needed methods.
  • When it works, you should be able to plot beautiful fractals.
Personal tools
translate