How to make the Julia fractal
I am going to jump straight in to this one. This fractal is just
a slightly modified equation of the Mandelbrot set. See my article on
the Mandelbrot set to understand more about this fractal.
The equation used for the Mandelbrot is:
zn+1 = zn2
z0 = 0 and c
to a point on the graph.
applying the equation until |z|>2 or you have
iterated a certain number of times.
To make the Julia fractal, I make the variable c a constant.
and z0 to be a point on the graph.
Here is a code fragment written in Java (easily converted to C++)
class JuliaPanel extends JPanel
public void paintComponent(Graphics g)
Rectangle r = getBounds();
double ExamineReal=0.32,ExamineImaginary=0.043;//constants to make the
I have set a variable to Zx*Zy just so I do not have to multiply these
again in the loop.
Now, to square a complex number, I expand this equation:
(Zx + Zyi)2 =
Zx × Zx + Zx × Zy
+Zx × Zy - Zy×Zy =
The real part is Zx2-Zy2.
It is quicker to multiply them together (the Zx*Zx part) than use a
function for raising a number to another.
imaginary part is 2(Zx×Zy). It is quicker to set a
n = Zx*Zy then set n = n + n to avoid multiplying by two (adding is
quicker than multiplying). Zy is a floating point number so I cannot do
a bit shift left to multiply by two.
Now the part that is different to the Mandelbrot set is that I am
adding constants called ExamineReal and ExamineImaginary. In the above,
I just use 0.32 + 0.043i but you can choose others. There are numerous
numbers which you can find to make all sorts of interesting shapes.
Here is some code for the Casio calculator. Note that it generates this
fractal very slowly. It looks almost identical to the Mandelbrot set souce code.
For Ymin→T To Ymax Step (Ymax-Ymin)÷62
For Xmin→S To Xmax Step (Xmax-Xmin)÷125
LpWhile Abs C≤2 And I<20
Abs C≤2⇒Plot S,T
| Have you found an error or do you want to add more
information to these pages?
You can contact me at the bottom of the home page.