Logo by Trifox - 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: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. December 02, 2025, 03:07:40 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: Kaliset frustration  (Read 4376 times)
0 Members and 1 Guest are viewing this topic.
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« on: March 14, 2012, 07:43:35 AM »

I must be missing something really obvious... I don't really know what I'm doing wrong. I just discovered this: http://softologyblog.wordpress.com/2011/05/10/more-ducks-and-kaliset-variations/

and I wanted to try out some of the formulas. The first one, z=1/abs(z)+c, seemed easy enough but didn't work for me. I don't have complex variables to work with, I have to keep track of real and imaginary myself:

- I use 'x' and 'y' to be the real and imaginary parts of 'c'
- I use 'zr' and 'zi' to be the real and imaginary parts of 'z'
- I assumed that the abs(z) is sqrt(zr*zr+zi*zi)
- I assumed that the abs(z) should only affect the real part of 'z'

In a double for loop that goes through all the 'x' and 'y' of the screen...
Code:
float zr = x;
float zi = y;
int n = 0;
while (n < maxIterations) {
  float zMag = sqrt(zr*zr+zi*zi);
  zr = 1/zMag+x;
  zi = y;
  if (zr*zr+zi*zi > 16) break;
  n++;
}
Logged
element90
Strange Attractor
***
Posts: 298



WWW
« Reply #1 on: March 14, 2012, 09:32:50 AM »

The abs function used in many formulae especially those derived from UF is NOT the magnitude of the complex number, the function strips the sign from both the real and imaginary components.

What programming language are you using?

If at all possible use a programming language that supports complex numbers as it will make your life much easier. As the complexity of the formula you wish to implement increases the difficulty in using pairs of real and imaginary numbers increases significantly especial when it comes to using non integer powers, complex powers, trig function etc. As a result implementing formulae is error prone.

An other thing to note about Ducks and Kaliset variations is that they usual do not have a bailout condition and are coloured using inner colouring techniques, exponential sum works well. Use a low number of iterations for example 40 or fewer.
Logged

Elelemt90 Fractals blog www.element90.wordpress.com
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #2 on: March 14, 2012, 04:51:01 PM »

Ah, that makes more sense then. I've never done inner coloring, I'll have to try that out before I get the equation going then. I'm using Processing and Java.
Logged
element90
Strange Attractor
***
Posts: 298



WWW
« Reply #3 on: March 14, 2012, 05:26:21 PM »

From a quick look on the web there are complex number packages available for Java, I haven't look far enough to find a suitable package to download, I'm sure that you can find a suitable package or ...

If some one on this form knows of a complex number package and where to download it from then please feel free to add to this thread.

It is worth your while using a complex number package rather than wasting your time doing complex number arithmetic and keeping track of the real and imaginary parts yourself with the all the associated debugging  as the package should've had most if not all the bugs squashed.
Logged

Elelemt90 Fractals blog www.element90.wordpress.com
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #4 on: March 14, 2012, 05:55:58 PM »

To be honest I would rather figure it out myself. It's pretty hard for me since I'm not used to it yet but I'll get it eventually.
Logged
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #5 on: March 15, 2012, 02:00:00 AM »

I'm having a really hard time finding an interior color tutorial, the Wikipedia explanation is complicated and I haven't had luck with Google. Could someone please explain (even without code) how this works or point me in the direction of a tutorial please.
Logged
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #6 on: March 15, 2012, 04:33:13 AM »

Ok, I found a nice tutorial. The part that is on interior coloring is here: http://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/Mandelbrot_set#Interior_of_Mandelbrot_set_-_hyperbolic_components

I tried to reproduce the first image I posted below (from the link). I ended up with something else, kind of like how it looks, but it definitely is different. Will the thing I made work for a Kaliset?

It shows an image that looks like this (this is what I tried to make):


It also has another image that looks like this (I think this is what I accidentally made but in 2D):


My result so far:
Logged
Kali
Fractal Supremo
*****
Posts: 1138


« Reply #7 on: March 15, 2012, 04:37:07 AM »

I'm having a really hard time finding an interior color tutorial, the Wikipedia explanation is complicated and I haven't had luck with Google. Could someone please explain (even without code) how this works or point me in the direction of a tutorial please.

A simple one could be to calculate the average value of the magnitudes at each iteration, then applying a color palette based on this result. Just store the sum of the magnitude values divided by the number of iterations you are doing (include a line like this on the iteration part: average=average+magnitude/maxiterations)

Best results are obtained using "exponential smoothing", or "exponential sum" as element90 pointed... here you must calculate the accumulation of the exponent of the magnitude change at each iteration, like this:

total = total + exp(-1/(abs(magnitude - previousmagnitude))

Then pick color based on the resulting total.

Btw, original Kaliset (http://www.fractalforums.com/new-theories-and-research/very-simple-formula-for-fractal-patterns/) uses real numbers only.

Good luck...

Kali
Logged

asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #8 on: March 15, 2012, 05:00:28 AM »

Thanks Kali, I'll try that out soon. One project obsession at a time... as soon as I figure out why I ended up with this technique instead of the one I shot for.

I just discovered the method I got to work so far looks a lot better for Julia Interiors. I don't know what the technique is called though, does anyone know? It was referred to as bof60 because it appears on page 60 in "The Beauty of Fractals". Not a very useful name for me.

Here's a Julia for c = (-0.75, 0):
Logged
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #9 on: March 15, 2012, 07:04:53 AM »

Kali, I tried out your equation and it makes some very nice results. However, it seems to have an interior and an exterior, maybe the method I used is not compatible? For the interiors I used the same method as the Mandelbrot and Julia I posted above but for the exteriors I just used standard Log Color (except that I left it blue to be able to differentiate easily).

Kalibrot result:


Kali-Julia at (-0.2, -0.1):
Logged
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #10 on: March 15, 2012, 08:31:43 AM »

Opps, my bad... I was rereading the posts and forgot element90 had said not to use a bailout.

No bailout, 50 Iterations, same color technique as above:
Logged
Adam Majewski
Fractal Lover
**
Posts: 221


WWW
« Reply #11 on: March 27, 2012, 09:58:48 PM »

>Here's a Julia for c = (-0.75, 0):
Looks intresting. Could you post code ?
Please note that this is parabolic Julia set, see :
http://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/parabolic

Code for bof 61 is here :
http://commons.wikimedia.org/wiki/File:Bof61.png
Logged
asimes
Fractal Lover
**
Posts: 212



asimes
WWW
« Reply #12 on: March 28, 2012, 05:41:33 AM »

Sure, this was written in Processing. If you have it this is ready to go

Code:
// Alex: This name comes from page 60 if the book "The Beauty of Fractals"
float xmin = -2;
float ymin = -2;
float wh = 4;
int maxIterations = 1000;

void setup() {
  size(800, 800, P2D);
}

void draw() {
  loadPixels();
  float xmax = xmin+wh;
  float ymax = ymin+wh;
  float dx = (xmax-xmin)/width;
  float dy = (ymax-ymin)/height;
  float biggestZMag = 0;
  int interiorCount = 0;
  float[] interiorDist = new float[width*height];
  int[] interiorLoc = new int[width*height];
  float x = xmin;
  for (int i = 0; i < width; i++) {
    float y = ymin;
    for (int j = 0;  j < height; j++) {
      float zr = x;
      float zi = y;
      float closestZMag = 1000000;  // Arbitrarily large
      int n = 0;
      while (n < maxIterations) {
        float zrr = zr*zr;
        float zii = zi*zi;
        float twori = 2*zr*zi;
        zr = zrr-zii-0.75;
        zi = twori;
        float localZMag = sqrt(zr*zr+zi*zi);
        if (localZMag < closestZMag) closestZMag = localZMag;
        if (zrr+zii > 16) break;
        n++;
      }
      if (n == maxIterations) {
        interiorDist[i+j*width] = closestZMag;
        interiorLoc[interiorCount] = i+j*width;
        interiorCount++;
        if (closestZMag > biggestZMag) biggestZMag = closestZMag;
      }
      else pixels[i+j*width] = 0xffffff;
      y += dy;
    }
    x += dx;
  }
  for (int i = 0; i < interiorCount; i++) {
    int interiorColor = int(sqrt(interiorDist[interiorLoc[i]])/sqrt(biggestZMag)*255);
    pixels[interiorLoc[i]] = interiorColor+(interiorColor<<8)+(interiorColor<<16);
  }
  updatePixels();
  println("Time: "+millis());
  noLoop();
}

void mousePressed() {
  wh /= 2;
  float xmax = xmin+wh;
  float ymax = ymin+wh;
  float dx = (xmax-xmin)/width;
  float dy = (ymax-ymin)/height;
  xmin += mouseX*dx;
  ymin += mouseY*dy;
  loop();
}
Logged
Adam Majewski
Fractal Lover
**
Posts: 221


WWW
« Reply #13 on: March 30, 2012, 05:18:14 PM »

Thx.
I have never seen  Julia image made with BOF60. It's interesting.
If yoy like you can add your image and src code to commons.
http://commons.wikimedia.org/wiki/Category:Julia_sets
There are some images made with Processing :
http://commons.wikimedia.org/wiki/Category:Processing_%28programming_language%29

Regards
Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #14 on: March 30, 2012, 10:38:35 PM »

For anyone reading this thread and encountering similar issues with respect to |z|, abs(z) and cabs(z) - a lot of fractal software (and languages they use for fractal coding) conform to the syntax of the mother/father of fractal software Fractint so if you want to be fairly sure you've got it correct then (in general) check the online docs for Fractint, but for this particular case in most fractal software for complex numbers if z = x+ i*y where x and y are real then:

abs(z) = abs(x) + i*abs(y)
|z| = sqr(x) + sqr(y) or x^2+y^2 if you prefer
cabs(z) = sqrt(sqr(x)+sqr(y)) or sqrt(x^2+y^2) or indeed sqrt(|z|)

i.e. abs(z) yields a complex result whereas |z| and cabs(z) yield reals.

The reason that |z| differs from the formal mathematical definition (i.e. the same as cabs(z)) is because it's so often possible to avoid the square root calculation such as when testing for bailout - also it should be noted that after |z| is calculated it can be worth retaining the value because often the actual magnitude (i.e. cabs(z)) is required (conditionally) afterwards and this can of course then be obtained via the sqrt alone without having to re-calculate x^2+y^2.
« Last Edit: March 30, 2012, 10:40:10 PM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Kaliset 4D Mandelbulb3D Gallery Kali 0 961 Last post May 14, 2011, 08:44:47 AM
by Kali
Kaliset + Rotations Other types Kali 11 13456 Last post June 07, 2011, 04:14:16 AM
by Kali
Extended Kaliset Images Showcase (Rate My Fractal) Kali 0 1840 Last post May 30, 2011, 05:56:41 AM
by Kali
Kaliset Explorer Images Showcase (Rate My Fractal) Kali 0 1270 Last post August 30, 2011, 07:23:51 AM
by Kali
FE Kaliset w/exp.smoothing Images Showcase (Rate My Fractal) Kali 3 3617 Last post February 14, 2012, 06:00:10 AM
by zonepatcher

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.479 seconds with 24 queries. (Pretty URLs adds 0.018s, 2q)