Welcome to Fractal Forums

Fractal Software => Programming => Topic started by: laser blaster on January 23, 2014, 04:29:48 AM




Title: Distance Estimation formula for the Burning Ship?
Post by: laser blaster on January 23, 2014, 04:29:48 AM
Hello, all. Does anyone know of a distance estimation formula for the 2D burning ship fractal? I'm assuming someone must know it because I've seen videos of a 3D ray-traced Burning Ship fractal. Also, I'd be interesting in an explanation for how the formula can be derived.


Title: Re: Distance Estimation formula for the Burning Ship?
Post by: hermann on January 23, 2014, 09:29:36 PM
The Formula can be found on the following Wikipedia site:
http://en.wikipedia.org/wiki/Burning_Ship_fractal (http://en.wikipedia.org/wiki/Burning_Ship_fractal)

In this forum you can find the following post's
http://www.fractalforums.com/general-discussion-b77/burning-ship-fractal/ (http://www.fractalforums.com/general-discussion-b77/burning-ship-fractal/)

You may also have a look on my personal burning ship page:
http://www.wackerart.de/burning-ship.html (http://www.wackerart.de/burning-ship.html)
I hope Java is active in your browser to explore some of my fractals online.

Hermann


Title: Re: Distance Estimation formula for the Burning Ship?
Post by: laser blaster on January 24, 2014, 10:18:51 PM
That's just the iterative formula for determining if a point is in the burning ship. Distance estimation is another beast altogether.

By the way, using the standard Mandelbrot DE method for the burning ship produces okay-looking, smooth results, but in some areas the DE formula overestimates/underestimates the distance far more than others, so the results aren't consistent, and in one particular are it fails altogether.

Perhaps trying to come up with an accurate DE formula for a non-analytic fractal like the burning ship is a fools errand. I'm going to go out on a limb and guess that the guy who programmed the 3D distance-estimated burning ship used the standard mandelbulb DE method, designed the formula of the fractal to cut out any "problem areas", used a high fudge factor, and hoped for the best.


Title: Re: Distance Estimation formula for the Burning Ship?
Post by: top-quark on April 20, 2014, 05:36:17 PM
Here's what I'm using:

Formula: zk+1 = (|re(zk)| + |im(zk)| * i)2 - c

Algorithm:

Parameters: cX, cY

Let:
x_ = cX, y_ = cY,
eV = 256,
iter = 0,
rsquared = x_ * x_ + y_ * y_,
dzx = 0, dzy = 0;                   // For accumulating ∂f(c) / dc

while (iter < MAX_ITER AND rsquared < eV) {
    // Take absolute values of re and im
    _x = x_ < 0 ? -x_ : x_;
    _y = y_ < 0 ? -y_ : y_;

    // Calculate dz
    tmp = 2 * (dzx * _x - dzy * _y) - 1;
    dzy = 2 * (dzx * _y + dzy * _x);
    dzx = tmp;

    // Real part
    x_ = _x * _x - _y * _y - cX;
    // Imaginary part
    y_ = 2 * _x * _y - cY;
    
    rsquared = x_ * x_ + y_ * y_;
}

if (iter < MAX_ITER) {
   Let:
   r = sqrt(rsquared),
   dz = sqrt(dzx * dzx + dzy * dzy),
   distance = log(r * r) * r / dz;
   if (distance < PIXEL_WIDTH / 20) {
       return BLACK;
   }
   else {
       return COLOUR;
   }
}
return WHITE;


Can be adapted for Julia set: initialize (x_, y_) to pixel, dz to 1, don't subtract 1 from dz each iteration.

Looks pretty fierce white on black:
(https://farm4.staticflickr.com/3731/13950144685_8d37efa50f.jpg) (https://flic.kr/p/nfJ8ZX)
burningship-distance-estimate-white-on-black (https://flic.kr/p/nfJ8ZX) by c.c.williams (https://www.flickr.com/people/123673293@N02/), on Flickr

Distance estimation doesn't outline the keel terribly well but works absolutely fine everywhere else, armada towers in particular, which suggests that it's fundamentally good. Works for Julia sets too.


Title: Re: Distance Estimation formula for the Burning Ship?
Post by: top-quark on April 20, 2014, 05:45:28 PM
I suspect that why the distance estimation breaks down at certain points is because functions like y = |x| aren't differentiable everywhere.