Logo by teamfresh - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Visit the official fractalforums.com Youtube Channel
 
*
Welcome, Guest. Please login or register. April 19, 2024, 12:01:25 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Need help with distance estimation formula for the Phoenix fractal  (Read 1259 times)
Description: Struggling with coming up with a working formula
0 Members and 1 Guest are viewing this topic.
top-quark
Forums Freshman
**
Posts: 10


« on: April 20, 2014, 02:36:12 PM »

I'm writing a fractal library in JavaScript for an online fractal exploration application (not yet live - I'm writing the documentation).

One of the formulae I'm offering is the Phoenix fractal. It's not looking too bad:


phoenx+0.5667-0.5P by c.c.williams, on Flickr

However, if I turn off exterior colouring and enable boundary tracing, things don't look so good:


phoenx-distance-estimate by c.c.williams, on Flickr

It looks wrong (doesn't exactly scream "nowhere dense") but not completely wrong (the shape is correct).

Formula: zk+1 = zk * zk + c + P * zk-1

Here's my algorithm:

Parameters: z, c, P

z_ (im(z), re(z)),    // side-by-side view
zlast = 0,
iter = 0,
eV = 256,
dz = 1,               // Cumulative differential of f(z_)
dzp = 0,              // Cumulative differential of P * f(zlast)
rsquared = re(z_) * re(z_) + im(z_) * im(z_);

while (iter < MAX_ITER && rsquared < eV) {
    _z = z_ * z_ + c + P * zlast;
    dz = 2 * z_ * dz + dzp;
    dzp = 2 * P * zlast * dzp;
    zlast = z_;
    z_ = _z;
    rsquared = re(z_) * re(z_) + im(z_) * im(z_);
}

if (iter < MAX_ITER) {
    r = |z_|;
    d = |dz];
    distance = log(r * r) * r / d;
    if (TRACE_BOUNDARY AND distance < PIXEL_WIDTH / 20) {
        return BLACK;
    }
    else if (EXTERIOR_COLOURING) {
         return COLOUR;
    }
}
return WHITE;



If any knowledgeable person can point me in the direction of where I'm going wrong in incorporating P * zlast into the cumulative differential of ∂f(z) / dz, I'd be very grateful.

(P.S. Distance estimate works fine for Mandelbrot / Multibrot / Burning Ship and corresponding Julia sets).
Logged
knighty
Fractal Iambus
***
Posts: 819


« Reply #1 on: April 23, 2014, 01:26:48 PM »

Formula: zk+1 = zk * zk + c + P * zk-1
Are you sure this is the formula for the phoenix fractal? isn't it:
   zk+1 = zk * zk + Re(c) + Im(c) * zk-1 ?
(Edit: unless c=Re(c) and P=Im(c) of course  embarrass)
This transformation being not conformal here is a routine that uses the jacobian matrix instead to compute DE for julia sets:
Code:
phoenix(x,y,cx,cy,mi){
   //the computation of the DE is for julia sets here-> cx and cy are constant
   lx=0; ly=0;//z[n-1]
   dlxx=0; dlxy=0; dlyx=0; dlyy=0;//Dz[n-1] (jacobian matrix)
   dxx=1; dxy=0; dyx=0; dyy=1;//Dz[n]
   r2=x*x+y*y;
   for(i=0; i<mi && r2<1024; i++){
      //Compute Dz[n+1]
 ndxx= 2*(x*dxx-y*dyx)+cy*dlxx;
      ndxy= 2*(x*dxy-y*dyy)+cy*dlxy;
      ndyx= 2*(x*dyx+y*dxx)+cy*dlyx;
      ndyy= 2*(x*dyy+y*dxy)+cy*dlyy;
      //set Dz[n-1]:=Dz[n]
 dlxx=dxx; dlxy=dxy; dlyx=dyx; dlyy=dyy;
 //set Dz[n]:=Dz[n+1]
      dxx=ndxx; dxy=ndxy; dyx=ndyx; dyy=ndyy;
      //compute z[n+1]
 nx= x*x-y*y+cx+cy*lx;
      ny= 2*x*y+cy*ly;
      //set z[n-1]:=z[n]
 lx=x;ly=y;
 //set z[n]:=z[n+1]
      x=nx; y=ny;
 //Modulus squared of z[n]
      r2=x*x+y*y;
   }
   r=sqrt(r2);//modulus of z[n]
   dr=max(sqrt(dxx*dxx+dxy*dxy),sqrt(dyx*dyx+dyy*dyy));//a norm of Dz[n]
   return max(0,0.5*r*log(r)/dr);//Distance estimate
}
« Last Edit: April 23, 2014, 08:24:55 PM by knighty » Logged
knighty
Fractal Iambus
***
Posts: 819


« Reply #2 on: April 23, 2014, 02:29:36 PM »

Oops! just realized that the phoenix julia set transformation is conformal just because c Is constant.

Code:
phoenix(x,y,cx,cy,mi){
   //x=cx; y=cy;
   lx=0; ly=0;
   dlx=0; dly=0;
   dx=1; dy=0;
   r2=x*x+y*y;
   for(i=0; i<mi && r2<10240; i++){
      ndx= 2*(x*dx-y*dy)+cy*dlx;
      ndy= 2*(x*dy+y*dx)+cy*dly;
      dlx=dx; dly=dy;
      dx=ndx; dy=ndy;
      nx= x*x-y*y+cx+cy*lx;
      ny= 2*x*y+cy*ly;
      lx=x;ly=y;
      x=nx; y=ny;
      r2=x*x+y*y;
   }
   r=sqrt(r2);
   
   dr=sqrt(dx^2+dy^2);
   max(0,0.5*r*log(r)/dr);
}
Logged
top-quark
Forums Freshman
**
Posts: 10


« Reply #3 on: April 25, 2014, 02:26:40 AM »

Thanks for the response. The formula I'm using uses two complex constants (Ushiki) rather than than real constants (Stevens). When P is 0, you have the quadratic Julia formula z -> z² + c. However, since an imaginary component in either c or P results in crap as far as I can tell, I may well change it to use real constants. I will
certainly try the dz calculation that you were kind enough to provide.

The examples, as you probably guessed, are using c=0.5667 and P=-0.5.
Logged
top-quark
Forums Freshman
**
Posts: 10


« Reply #4 on: April 25, 2014, 08:37:38 PM »

Works absolutely perfectly. Muchas gracias!
Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #5 on: April 25, 2014, 08:54:23 PM »

so, what about a 3d version then ? cheesy
Logged

---

divide and conquer - iterate and rule - chaos is No random!
top-quark
Forums Freshman
**
Posts: 10


« Reply #6 on: April 26, 2014, 12:00:41 AM »

I'll have to teach myself WebGL first, so maybe a project for the future. A decent JavaScript engine is impressively fast at floating point calculations and web workers suppress slow script warnings so it should be doable.

Right now, I'm trying to get boundary tracing for Newtonian fractals working.
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Convergent Distance Estimation Programming David Makin 9 9277 Last post November 28, 2008, 10:27:01 PM
by gamma
Convergent Distance Estimation Mathematics David Makin 4 12653 Last post April 08, 2009, 10:07:14 PM
by David Makin
Juliabrot raytracing and distance estimation 3D Fractal Generation fractalrebel 1 2566 Last post November 22, 2009, 01:32:26 PM
by David Makin
Pseudo Distance Estimation Mandelbulb Implementation JColyer 3 5286 Last post January 09, 2010, 03:30:09 PM
by JColyer
Distance Estimation formula for the Burning Ship? Programming laser blaster 4 5846 Last post April 20, 2014, 05:45:28 PM
by top-quark

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.161 seconds with 24 queries. (Pretty URLs adds 0.01s, 2q)