Home • Essays • Lost Articles • Loose Ends • Collections • Computing • Projects • Widdershins • Quotations • Links • Us


Julia Sets

Fractal Madness




iter = 150   'number of iterations of a selected coordinate, more makes for more detail
xorg = 0.1  'starting x coordinate on the Cartesian plane (the Real portion)
yorg = 0.5608   'starting y coordinate on the Cartesian plane (the Imaginary portion)
x = xorg
y = yorg

  'inc=how far we will step the x and y coords each time

  'you can see that this is a pretty fine stepping increment, just covering a very small area
inc = 0.000000001  
  'kx and ky are constants added to the result of each iteration calculation
kx = -0.745 
ky = 0.15
  'xp and yp are screen coordinates, assuming 600 X 400 display
For xp = 1 To 600 Step 0.5
    x = x + inc
    xs = x
    y = yorg
    ys = y
    For yp = 1 To 400 Step 0.5
        For i = 1 To iter
              'with xx being the real part and yy being the imaginary part of the complex
              'number -- we are squaring the complex number and adding the Julia
              'constants after each iteration             
            xx = x * x - y * y
            yy = 2 * x * y
            x = xx + kx
            y = yy + ky
              'this is the "jump out" limit, if the result diverges
            If Abs(x) > 2500000 Or Abs(y) > 2500000 Then i = iter
          'figure the colors to plot, based on how big the iterative calculation got
        If xx <> 0 Then nc = Log(Abs(xx) ^ 14)
        cc = Abs(nc)
        If yy <> 0 Then nc = Log(Abs(yy) ^ 8)
        cd = Abs(nc)
        If xx <> 0 And yy <> 0 Then nc = Log(Abs(xx * yy) ^ 2)
        ce = Abs(nc)
        If cc > 256 Then cc = 256
        If cd > 256 Then cd = 256
        If ce > 256 Then ce = 256
          'plot the point (this PSET plot function is given here in VB format)
        Picture1.PSet (xp, yp), RGB(cc, cd, ce)
          'step the complex coordinate and do it for the next screen point
        ys = ys + inc
        y = ys
        x = xs

Below is an example of the graphical output of this kind of code, given particular starting parameters (number of iterations, step size, starting x and y coordinates, k numbers, "jump out" limit). I must admit that I think this image also included a trick routine to "shade" the pixels that were on the "underside".  I will let you explore how to do that yourself...


Julia sets are mathematical functions defined by iterative squaring of x-y coordinates in the complex number plane. I have played around with these for years on my PC. Here is a piece of Basic code that will produce Julia sets:




First-time visitors -- including you!

Free Web Counter

Free Hit Counter The Foggiest Notion The Foggiest Notion The Foggiest Notion The Foggiest Notion The Foggiest Notion


Luck Favors the Prepared Mind...

Essays • Lost Articles • Loose Ends • Collections • Computing • Projects • Widdershins • Quotations • Links • Us

Site contents Copyright 2004-2008 by Gary Cuba       Email: webmeister at thefoggiestnotion dot com