This is the first installment
of your second project. My intent is that this second project is
much more modest than the MazeWar project. Although it may be
less fun as well, there are several interesting facets of the project
that may make it interesting for you. Do not wait until the last
to work on the project deliverables. You will suffer in many ways
if you do. The first
deliverable is due Thursday Nov. 30 at 8:00am
. This is an
individual project. As always, I encourage you to talk to your
peers or to me and to ask questions. But the code you submit must
be your own code.
The second project, once implemented, will display a rendering of the
Mandelbrot Set for a given region of the complex plane. We'll go
over the math in class. You can learn much more than you need for
the project at the Wikipedia site for
the Mandelbrot Set
. The Wikipedia page has pseudocode that
take you most of the way.
Deliverable 2.1 Draw the
Mandelbrot Set in two colors
Determining set membership
Write a function, "inMandelbrotHuh(Point2D.Double)", that consumes a
java.awt.Point2D.Double and returns a boolean value. The truth
value determines if the given point belongs to the Mandelbrot set
(true) or not (false). Note, the Point2D.Double is a point on the
complex plane but corresponds to a pixel of your canvas that might be
represented as a Point or a Point2D. If you follow the pseudocode
found at the Wikipedia site you should be fine. But spend some
time trying to understand the pseudocode -- we'll be going over it in
class on Tuesday. Update
11/27: Yes, you can copy the pseudocode and convert it to Java.
However, you may not share your code with your peers.
Display the image.
Display the points of the complex plane in the range [-2,1] to
[1,-1]. Naturally, you'll need to map this region of the plane
onto your canvas with upper-left corner [0,0] (actually, the
appropriate value allowing for Insets) and a particular width and
height. You should code this mapping in a way that will allow
maximal generality because next week you will be zooming in and out
while recentering the portion of the plane that is visible on the
canvas. The resulting image should have two colors. Points
in the Mandelbrot
set should be colored black, and other points should be colored a color
of your choosing.
display code should render the picture in a manner that provides progressive detail
. That is,
your code should break the region to be rendered into four rectangles
and render those according to the mid-point of the rectangles.
But then each rectangle should be further subdivided into four
rectangles and the process repeated. This continues until the
rectangle fits on a single pixel. Update 11/27: Your code should paint
the canvas according to the membership of the center of the canvas,
then divide the canvas into four regions and paint each region
according to the membership of the respective midpoints of each region,
and repeat this subdivision process until the region corresponds to a
single pixel. Furthermore, all of the regions at a given
granularity should be painted before any of them are further painted at
a finer granularity.
Wrap all this
functionality in a "Mandelbrot" class, which extends Frame.
Include a main method that will display the image. In your
submitted code, use a canvas width and height of 600x400 and maximum
iterations threshold of 100 -- you can play with these on your own and
we will change them later.
On your machine where you are doing your homework, create a folder
called <your email name> followed by "P2.1". For example,
with email address "cjones" would create
a folder called
Inside that folder, place whatever Java files are necessary
your Programming Projects in the same folder. Finally, either tar
zip the folder so that when
extracted, the folder
"<emailname>P2.1" will be created. Finally, submit via Eureka.