Welcome to Fractal Forums

Fractal Software => Programming => Topic started by: Kalles Fraktaler on July 31, 2014, 10:12:59 PM




Title: Magnetic Mandelbrot
Post by: Kalles Fraktaler on July 31, 2014, 10:12:59 PM
I want to do the Magnetic Mandelbrot 1 fractal and eventually find the perturbation method for it.
However I only get almost all orbits trapped, i.e. an almost only black picture, no matter how high I set the maximum iteration.
But it has some expected shapes.
What am I doing wrong? Is there a different bailout criteria?

(http://www.icd.com/tsd/fractals/beginner/equation2.gif)
Code:
	std::complex<double> Z(Zr,Zi), C(m_pX[x],m_pY[y]), _1(1,0), _2(2,0);
std::complex<double> T = (Z*Z) + (C-_1);
std::complex<double> N = Z*_2 + (C-_2);
std::complex<double> K = T/N;
Z = K*K;
Zr = Z.real();
Zi = Z.imag();


Title: Re: Magnetic Mandelbrot
Post by: cKleinhuis on August 01, 2014, 11:35:17 AM
yes there is, in the ultrafractal formula definition bailout criteria is:


  |z| < @bailout && |z - 1| > @lowerbailout

lowerbailout defaults to "0.0005"

but i checked it, this part of the bailout is not so siginificantly influencing the image, at least i did not end with an image like yours when removing that part!


Title: Re: Magnetic Mandelbrot
Post by: Roquen on August 01, 2014, 03:11:12 PM
Is this what you expect: http://glsl.heroku.com/e#18816.0


Title: Re: Magnetic Mandelbrot
Post by: 3dickulus on August 06, 2014, 04:45:46 AM
Or this ?

Code:
/***************************************************************************
                          qtfmag.cpp  -  description
                             -------------------
    begin                : Wed Sep 5 2001
    copyright            : (C) 2001 by 3Dickulus.
    email                : ***@****.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "qtfpainter.h"

/**********************************************************
 *
 *               Magnetic funcs
 */

void QtfPainter::mag0func( double r,  double i)
{
  uint count = 0;
  double p;
  double q;
  double a;
  double b;
  double mag;
  double dr = divergence*0.33333;

  while ( count++ < maxiter)
  {
    a = r * r - i * i + 3;
    p = (r + r);
    b = p * i;
    p += 2;
    q = i; q += i;
    mag = (p * p + q * q);
    r = (a * p + b * q) / mag;
    i = (p * b - a * q) / mag;
    a = r * r - i * i;
    i = dr * r * i;
    r = a;

    if ( (fabs(r-1) + fabs(i)) < 0.0001)
    {
      count |= 16;
      break;
    }
    if ( fabs(a) > 10000) break;

  }

  coltmp = (count >= maxiter) ? 0 : ( count % maxcol + 2 );

return;
}

void QtfPainter::mag1func( double r,  double i)
{
  uint count = 0;
  double p;
  double q;
  double a;
  double b;

  double dr = divergence*0.33333;

  double mag,magr,magi;

  magr = r + 1;
  magi = i;

  r = 0;
  i = 0;
  while ( count++ < maxiter)
  {
    a = r * r - i * i + magr - 1;
    p = b = (r + r);
    p += magr; p -= 2;
    b *= i; b += magi;
    q = i; q += i; q += magi;
    mag = (p * p + q * q);
    r = (a * p + b * q) / mag;
    i = (p * b - a * q) / mag;
    a = r * r - i * i;
    i = dr * r * i;
    r = a;

    if ( (fabs(r-1) + fabs(i)) < 0.0001)
    {
      count |= 16;
      break;
    }
    if ( fabs(a) > 10000) break;
  }
  coltmp = (count >= maxiter) ? 0 : ( count % maxcol + 2 );

return;
}


void QtfPainter::mag2func( double r,  double i)
{

  uint count = 0;
  double p;
  double q;
  double a;
  double b;
  double mag;
  double dr = divergence*0.33333;

  while ( count++ < maxiter)
  {
    a = r * r - i * i + 9;
    b = 2 * r * i;
    p = a * r - b * i + 6;
    q = a * i + b * r;
    a = 3 * (r * r - i * i) + (6 * r) + 7;
    b = 3 * (r * i + r * i) + (6 * i);
    mag = a * a + b * b;
    r = (p * a + q * b)/mag;
    i = (a * q - p * b)/mag;
    mag = r * r - i * i;
    i   = dr * r * i;
    r   = mag;

    if ( (fabs(r-1) + fabs(i)) < 0.0001)
    {
      count |= 16;
      break;
    }
    if ( fabs(a) > 10000) break;
  }
  coltmp = (count >= maxiter) ? 0 : ( count % maxcol + 2 );

return;
}


void QtfPainter::mag3func( double r,  double i)
{
  uint count = 0;
  double p = r + 1;
  double q = i;
  double a;
  double b;
  double dr = divergence*0.33333;

  double re, im;
  double ren, imn;
  double ret, imt;
  double mag,magr,magi;

  re = (p - 1) * (p - 2) - q * q;
  im = q * (2 * p - 3);
  magr = p * p - q * q - 3 * p + 3;
  magi = 2 * p * q - 3 * q;
  r = 0;
  i = 0;

  while ( count++ < maxiter)
  {
    ren = r * r - i * i;
    imn = 2 * r * i;
    a = ren + 3 * (p - 1);
    b = imn + 3 * q;
    ret = a * r - b * i + re;
    imt = a * i + b * r + im;
    a = 3 * ren + 3 * ((p - 2) * r - q * i) + magr;
    b = 3 * imn + 3 * (q * r + (p - 2) * i) + magi;
    mag = a * a + b * b;
    r = (ret * a + imt * b) / mag;
    i = (a * imt - ret * b) / mag;
    a = r * r - i * i;
    i = dr * r * i;
    r = a;

    if ( (fabs(r-1) + fabs(i)) < 0.0001)
    {
      count |= 16;
      break;
    }
    if ( fabs(a) > 10000) break;
  }
  coltmp = (count >= maxiter) ? 0 : ( count % maxcol + 2 );

return;
}


EDIT: image 1x generated by mag0func
         image 1q generated by mag1func
         the other 2 funcs are variants of these two