Welcome to Fractal Forums

Fractal Software => Programming => Topic started by: tyebillion on January 20, 2013, 06:17:42 PM




Title: Crystal fractals: Barnsley / fish variations
Post by: tyebillion on January 20, 2013, 06:17:42 PM
Hi,
Back in the nineties I wrote a fractal generator program called Minifrac, written in Delphi which I never finished and never released.  The program was unremarkable except that it had two fractal variations (Crystal 1 and Crystal 2) that I found myself, and also a nice palette generator.  Below is the Pascal code for the two Crystal fractals for anyone who is interested.  For the Mandelbrot version the initial values are x = 0 and y = 0, with the point on the screen assigned to (a, b).  Whereas the Julia sets for these fractals have parameters (a, b) and the point on the screen assigned to (x, y).  For iterations that do not escape, I used the minimum of the norm squared (e.g. x*x + y*y) to colour the interior points.  Attached is a nice zoom of one of these fractals, sorry I forget which one it is, although I remember that it is a Mandelbrot.

Code:
{ CRYSTAL 1 - Barnsley fish variant }
c := 0;
d := 0;
nz2_min := LARGE;
nz2 := 0;
while (nz2 < nz2_max) and (iters < term_iters) do begin
    e := x;
    f := y;
    if x >= 0 then begin
p := x*c - y*d - a;
y := y*c + x*d - b;
x := p;
    end else begin
p := x*c - y*d + a;
y := y*c + x*d + b;
x := p;
    end;
    c := e;
    d := f;
    nz2 := sqr(x) + sqr(y);
    if nz2 < nz2_min then nz2_min := nz2;
    inc(iters);
end;

{ CRYSTAL2 - Another sort of barnsley fish variant }
c := 0;
d := 0;
nz2_min := LARGE;
nz2 := 0;
while (nz2 < nz2_max) and (iters < term_iters) do begin
    e := x;
    f := y;
    if x >= 0 then begin
p := x - c;
y := y - d;
x := a*p - b*y + 1;
y := a*y + b*p;
    end else begin
p := x + c;
y := y + d;
x := a*p - b*y - 1;
y := a*y + b*p;
    end;
    c := e;
    d := f;
    nz2 := sqr(x) + sqr(y);
    if nz2 < nz2_min then nz2_min := nz2;
    inc(iters);
end;


Title: Re: Crystal fractals: Barnsley / fish variations
Post by: Alef on August 18, 2013, 06:55:04 PM
Tested.
A first formula was kind of not worth to add to my formula file, but second crystal generated quite a nice Julias. Alsou added dual convergent and divergent bailout like of magnet what allows to see more outside patterns and some more variables for tweaking.
Didn't use any layering, as it is.

(http://www.ljplus.ru/img4/a/s/asdam/crystal1.jpg)

(http://www.ljplus.ru/img4/a/s/asdam/crystal2.jpg)

(http://www.ljplus.ru/img4/a/s/asdam/crystal3.jpg)

(http://www.ljplus.ru/img4/a/s/asdam/crystal41.jpg)


UF'll work after updating formulas

Code:
crystal4 {
fractal:
  title="crystal4" width=640 height=480 layers=1
  credits="Edgar;8/18/2013"
layer:
  caption="Background" opacity=100
mapping:
  center=0/0 magn=1.04
formula:
  maxiter=140 percheck=off filename="em.ufm" entry="Crystalfractal"
  p_bailout=10000000000 p_lowerbailout=9E-5 p_addval=1 p_settype=Julia
  p_switchsettype=Mandelbrot p_julia=-0.7/0.225 f_func_post=abs
  p_inverted=no p_fishstrenght=2 p_riselast=yes p_riselastpower=-1
inside:
  transfer=none solid=4278190114
outside:
  transfer=linear filename="em.ucl" entry="Pauldebrots_Smooth"
  p_convergent=no p_esm=no p_alt=no p_perfix=1.0 p_zmax=100 p_power=2
  p_fit=yes p_fittimes=1.0 p_fitminit=89 p_fitmaxit=140 p_transfer=Log
  p_transpower=3.0 p_bailout=10000000000
gradient:
  smooth=yes rotation=68 index=52 color=0 index=126 color=16121855
  index=263 color=0 index=389 color=33023
opacity:
  smooth=yes index=82 opacity=255 index=220 opacity=255 index=315
  opacity=255 index=358 opacity=255 index=377 opacity=255
}


Title: Re: Crystal fractals: Barnsley / fish variations
Post by: tyebillion on August 19, 2013, 06:13:19 PM
Good work, well done!  I like the images.  What program did you use?

Here is a tweak to try.  The cut off line x=0 could be rotated using a parameter.  Below is the code.  It could be interesting to animate a Julia set by changing this parameter t from 0 to 2*pi (radians).

Code:
{ CRYSTAL 1 - Barnsley fish variant }
c := 0;
d := 0;
u := cos(t);
v := sin(t);
nz2_min := LARGE;
nz2 := 0;
while (nz2 < nz2_max) and (iters < term_iters) do begin
    e := x;
    f := y;
    if (x*u - y*v) >= 0 then begin
p := x*c - y*d - a;
y := y*c + x*d - b;
x := p;
    end else begin
p := x*c - y*d + a;
y := y*c + x*d + b;
x := p;
    end;
    c := e;
    d := f;
    nz2 := sqr(x) + sqr(y);
    if nz2 < nz2_min then nz2_min := nz2;
    inc(iters);
end;

{ CRYSTAL2 - Another sort of barnsley fish variant }
c := 0;
d := 0;
u := cos(t);
v := sin(t);
nz2_min := LARGE;
nz2 := 0;
while (nz2 < nz2_max) and (iters < term_iters) do begin
    e := x;
    f := y;
    if (x*u - y*v) >= 0 then begin
p := x - c;
y := y - d;
x := a*p - b*y + 1;
y := a*y + b*p;
    end else begin
p := x + c;
y := y + d;
x := a*p - b*y - 1;
y := a*y + b*p;
    end;
    c := e;
    d := f;
    nz2 := sqr(x) + sqr(y);
    if nz2 < nz2_min then nz2_min := nz2;
    inc(iters);
end;


Title: Re: Crystal fractals: Barnsley / fish variations
Post by: Alef on August 20, 2013, 04:47:55 PM
Its a Ultra Fractal save file. But I alsou put it in Chaos Pro, what is a non comercial clone of UF.

@ is user changable parameters and flip generates imaginary value.
Code:
loop:

complex oldz =z

oldx=x
oldy=y

IF x >= 0
temp = x - olderx
y = y - oldery
x = cx*temp - cy*y + @addval
y = cx*y + cy*temp
ELSE
temp = x + olderx
y = y + oldery
x = cx*temp - cy*y - @addval
y = cx*y + cy*temp
ENDIF

olderx=oldx
oldery=oldy

z=x+flip(y)

IF  (@riselast)
z=z^@riselastpower
ENDIF

bailout:
  |z| < @bailout && |z - oldz| > @lowerbailout



Title: Re: Crystal fractals: Barnsley / fish variations
Post by: tyebillion on August 20, 2013, 08:47:17 PM
Thanks for the info, good idea to turn the "1" into a parameter.
What do you think of trying the tweak I mentioned?

I would like to try my formula in Ultra Fractal as my original program only does 640x400 pixels.

I found an interesting zoom on the Crystal2 Mandelbrot, around x=-0.726282702589718, y=-0.349032801550238.  It looks like "flags" or "fish bones".  By the way I used a "bailout" of 10 (= x^2 + y^2), I think that would be equivalent to 100 in your code, but I am not sure.  Anyway I included a picture of the Crystal2 Mandelbrot below.

I couldn't find the location of the "atoms" in my first picture, I never wrote down the co-ordinates.


Title: Re: Crystal fractals: Barnsley / fish variations
Post by: tyebillion on August 27, 2013, 03:36:30 PM
I tried my formula in Ultra Fractal.  Here is the code I used:

Code:
Crystal2b {
  init:
       if (@mset == 0)
         c = #pixel
         z = 0
       else
         c = @juliac
         z = #pixel
       endif
       z1 = 0
       u = cos(@theta)
       v = sin(@theta)
  loop:
         z2 = z

         if (real(z)*u - imag(z)*v >= 0)
            z = z - z1
            z = z*c + @alpha
         else
            z = z + z1
            z = z*c - @alpha
         endif

         z1 = z2

  bailout:
          |z| < @bailout
}