Please support this site by getting t-shirts and gifts at MagentaStudios.com!


JavaMan
  Mandelbrot Fractal Generator
   Java Applet by Nick Lilavois

What is this thing?

This is a Fractal generator written in the Java programming language. It generates the most widely recognized fractal (the Mandelbrot set), and a few other fractal equations. If your Web browser supports Java, you will see the Mandelbrot set at the top of this page. Both Netscape Navigator and Microsoft Internet Explorer support Java applets. It looks it's best if your computer is set to the HiColor mode (thousands of colors) or the TrueColor mode (millions of colors).


How to use the Applet

You can zoom into the fractal image by either clicking on it or drawing a square around an area. The best places to zoom in are right on the edge of the black shape, near the colored bands. You can also set the fractal's parameters in each of the selectors and fields to the left of the fractal image.

The first selector is the formula selector. With this box you can choose which fractal formula will be rendered. The first option on the list is the Mandelbrot set. This applet has a highly optimized Mandelbrot equation, and that formula will render much faster than any of the other formulas.

The second selector is the plane selector- what the plane options are is explained below in the Introduction to Fractal Mathematics section.

Next you will see the rendering mode selector, which determines what values will be used to assign colors to the image.

Each of the formulas in the formula selector have exponent values, many of which can be changed with the A1, A2, and A3 fields.

The next four fields are the four coordinate values used to determine the center of the image you see. Two of those four coordinates are used as the X,Y values to draw the image, the other two coordinates determine which "slice" of this plane you are looking at. Which ones are used for which is determined by which plane you selected. When you zoom into the fractal, you will notice that two of the four coordinates change, indicating that the point you clicked or area you selected is now the center of the image. The coordinate values should be between -2.00000 and 2.00000, because the entire fractal exists inside a 4D sphere with a radius of 2, centered on the origin.

Zoom is a percentage- a smaller number is a smaller fractal (zoomed out) a larger number is a larger fractal (zoomed in). The zoom field has two small buttons next to it- the plus button will zoom in, the minus button will zoom out.

Magnitude defaults to 4. A higher number will space out the bands, and a smaller number will tighten the bands.

Depth specifies the maximum render depth to calculate. Depth needs to be an integer above 1. The higher the number, the more accurate the fractal approximation, and the longer it will take to render. As you zoom in, increase the depth value to see more detail. Color indicates the total number of hues to use to define the bands in the image. To see the most detail, keep this value about the same as the depth value.

Note: If you are in 256 color mode, set the color value to 30- that will give you a hue range that falls within the web safe palette. If you set a higher color number, adjacent bands could be drawn with the same colors, making the bands indistinguishable.

Each of the coordinate fields, and each or the other fields, have two buttons on their right edge. The top one has a plus on it, the bottom one has a minus on it. Clicking one of those buttons will increment or decrement the value and begin a render.

Near the bottom of the control panel is the thumbnail view. It will only show up if you are using the mandelbrot object. The crosshairs show you where the point you are exploring is located on the Mandelbrot set, or how a Julia set or other plane relates to the Mandelbrot set.

Under the thumbnail are two buttons- to Reset the fractal to default values, or render the fractal based on the values you have selected.

Launch Applet Window

You can launch the applet in it's own window to see larger images of the fractals. You can launch it with full parameter controls like the one on the top of this page, or as just a Mandelbrot explorer.

Full parameter controls:

Choose one of these larger sizes if your monitor is set to 1024x768 or higher resolution: 700 pixels square or 600 pixels square.
Choose this medium size if your monitor is set to 800x600 or higher resolution: 500 pixels square.
Choose one of these smaller sizes if your monitor is set to any resolution: 400 pixels square or 300 pixels square.

1600 x 1200 pixels square 100% square

Just the Mandelbrot explorer:

Choose one of these larger sizes if your monitor is set to 1024x768 or higher resolution: 700 pixels square or 600 pixels square.
Choose this medium size if your monitor is set to 800x600 or higher resolution: 500 pixels square.
Choose one of these smaller sizes if your monitor is set to any resolution: 400 pixels square or 300 pixels square or 200 pixels square.


Saving Fractal Images

There is currently no way to save the images directly to your hard disk. If you want to keep one and you are using Microsoft Windows 95, 98, or NT, you can copy the screen to the clipboard by pressing the "Print Screen" button. You can then paste the image into any application that supports bitmapped graphics, such as Adobe Photoshop or the Windows Paint accessory. If you are on a Macintosh, press "Apple-shift-3" to save the contents of your screen to a PICT file called "Picture 1" in the root window of your primary hard disk.

Fractal Gallery

Each of these links will open a Java applet window showing some specific fractal images.
These are based on the The Mandelbrot Set formula, which is Z=Z2+C.

The Mandelbrot Gemstone.
Your Brain on Drugs.
Your Other Brain on Drugs.
Curl.
Cave Paintings at Lascaux.
Infinity. Just keep pressing the "Zoom Out" button.

These are based on the The Dragon Set formula, which is Z=C*Z*(1-Z).

The Genesis Bomb.
Peacock Tail.

These are based on the other formulas.

The Star of David.


Introduction to Fractal Mathematics

Fractal Theory

Fractals are unusual geometric shapes that break the rules of traditional geometry.

Most geometric shapes, like circles, triangles, rectangles, and other polygons, have a specific measurable perimeter, and a specific measurable area. As you zoom in to the perimeter of most geometric shapes, all you see is a smooth line or curve.

Fractals are different- their areas and perimeters are infinite.
The farther you zoom in to the perimeter of a fractal, the more bumps, curves, folds, spikes, and curls you see. With all that detail, the exact distance around the fractal is impossible to measure.

Because they are infinite, there is no way to draw the complete shape of a fractal. All we can do is approximate it's shape. The approximation used in a particular fractal image is referred to as the depth of the fractal. The greater the depth, the closer the image approximates the actual shape.

Kinds of Fractals

Fractals can be classified into two distinct groups: self-similar and self-repeating.

A self-repeating fractal contains an infinite number of exact replicas of itself throughout its graph, so as you zoom in you see the exact same thing you saw zoomed out. These are generally known as L-systems, Graftals, IFS theory fractals, etc. These use simple recursive formulas, and are simple repetitious images. Two examples are the Von Koch curve and the Sierpinski triangle.


If you are interested in seeing some nicer pictures of self-repeating fractals, try
http://www.wmin.ac.uk/~storyh/fractal/frac.html
which has a good Java applet that generates them.

Far more interesting than the self-repeating fractals are the self-similar fractals, which have a repeating resemblance on high magnifications, but are never exactly the same. The rest of this page only deals with the most popular self-similar fractal, the Mandelbrot set.

Fractal Mathematics

Self-similar fractals are generated by recursively iterating formulas, which are complex polynomials of the form z=f(z), and plotting their graphs. The Mandelbrot Set is the most commonly recognized fractal object, named after the father of fractal mathematics, Benoit B. Mandelbrot. It is the graph of the equation Z=Z2+C.

In the equation Z=Z2+C, 'Z' and 'C' are complex numbers. The complex number 'C' remains a constant value, while the complex number 'Z' varies each time the function is calculated, since the formula is set equal to Z.

Complex numbers are numbers that contain the square root of -1,
which is called the imaginary number.
The imaginary number is written as the italics letter i in mathematical formulas.

A complex number like Z or C isn't actually a single number value, it represents a formula i*i+r. That means any complex number contains two actual number values:

Fractal Graphics Programming

For the Mandelbrot formula, you have the two complex numbers Z and C, and each of these has two components i and r, resulting in four distinct variables, Zi, Zr, Ci, and Cr.

Because of the nature of complex numbers, Z=Z2+C isn't the actual calculated formula, but an abbreviation for two more "useable" formulas:

In order to render any mathematical formula as an image, we assign variables to coordinates, like X, Y and Z. Since the Mandelbrot set has four variables, These four variables can be thought of as four separate coordinates. With four coordinates, each complex polynomial containing two complex numbers defines a single fourth dimensional object!

If we could show the entire fourth dimensional object for each function, we would see all of the possible solutions to that function. But, there is no way to accurately depict a 4D object in 3D space, much less on a 2D computer screen, so fractal generators render the second dimensional cross-sections or "slices" of those fourth dimensional objects.

You can think of a fractal generator as working a lot like a MRI scan; as the medical scanner crosses over a patient's body, the doctor sees a computer graphic representation of a 2D cross-section of a 3D object, in that case, a patient. The images from a fractal generator do not represent the appearance of the entire 4D fractal object any more than a single MRI scan image represents an entire human being, or a single slice of bread represents the entire loaf.


A cross-section of a human head from the Visible Human Project.


In the third dimension there are three coordinates (x,y,z) creating three 2D planes (XY,XZ,YZ), thus there are three possible ways to slice a 3D object. (True, you can use oddly skewed planes, but we won't deal with those possibilities.)

There are six 2D planes in fourth dimensional space. We will call these planes C, Z, R, I, A and B. Planes are determined by which two of the four coordinate values (Zr,Zi,Cr,Ci) are used for our 2D image, and which two become constants. Two of the four values will be assigned to the 2D coordinates (X,Y) of the fractal image's center point, and the other two will become the constants R and I.

For example, The `C' plane uses the two values of C: (Cr,Ci), as (X,Y), while Zr becomes the constant R, and Zi becomes the constant I.

Here is a table showing how the six planes map to a computer screen:
Plane the four coordinates Fractal Name
X Y R I  
C Cr Ci Zr Zi The MANDELBROT set is on this plane.
Z Zr Zi Cr Ci The JULIA sets are on this plane.
R Cr Zr Zi Ci The REAL plane.
I Zi Ci Cr Zr The IMAGINARY plane.
A Zr Ci Cr Zi Some plane we'll call A.
B Cr Zi Zr Ci Some other plane we'll call B.

To draw the most common slice of the Mandelbrot set, we input the 2D coordinates (X,Y) for each pixel into the complex number C as (Cr,Ci). Ci is assigned to the Y or vertical axis, and Cr is assigned to the X or horizontal axis. We use 0 for both of the constants Zr and Zi.

With our four coordinates for a single point defined, we calculate the formula to get a color for each pixel. The number of times the formula is iterated before it reaches a defined magnitude value determines what color index to use. The magnitude is usually set to 4, and in programming terms that's when ((Zr*Zr)+(Zi*Zi)) > 4. There are areas of the fractal where the magnitude will never be reached, so that is why we limit it by a certain depth value- if it doesn't reach magnitude after depth iterations, it is considered to have a depth of and the pixel is black.

When you render it, you can see that the entire Mandelbrot set falls inside a circle with a radius of 2 centered at the origin. With a depth (approximation level) of 2, all you would see is a circle. As we increase the depth, more and more folds are visible.

Fractal Philosophy

Fractal mathematics broke barriers imposed by standard "Euclidean" geometry. Fractal mathematics showed that shapes and patterns previously believed to be random and organic, could conceivably be created by mathematical principles. This could impact the biological sciences such as botany, genetics, and medicine, and other fields such as physics, astronomy, and religion.

Just as there is a genetic code within each of us, could there be a fractal equation for the universe?

Fractal Links

Major Fractal sites:

Applied Fractals: