Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => The 3D Mandelbulb => Topic started by: Aexion on December 22, 2011, 04:15:30 PM




Title: Iterating C
Post by: Aexion on December 22, 2011, 04:15:30 PM
Hello,

Here is something interesting that I lately have been researching:
One of the fractal rule is that C is fixed value for the mandelbrot and julia iterations. This produces the fractals that you everyday see.
Well, I have experimented with a variable C, instead of a fixed one, and for many fractals I got interesting results.
The idea is this one (excuse my english, its not very good):
For every iteration step, you're really transforming the space into another space and subsequent iterations continue transforming the space.
For a mandelbulb, it means 3D rotation and scaling, and since the value of C is fixed for the iteration, that value doesn't follow the space transformations.
My idea was to make C to follow the transformations, but only the rotations, not the scale transformation.
This means that for every iteration, there's a different C value, at the same radius of the original one, but in a different position, but also, it correspond to the transformed value (Z).

This is my pseudo-code (its unoptimized and horrible, but was for testing purposes):
For every iteration:
I first calculate the classic mandelbulb and add the C value (cx,cy,cz)
Then transform the C value with the same function as the mandelbulb, but without changing the radius.

Code:
//Mandelbulb Iteration
const float r = sqrt(x*x + y*y + z*z);
const float theta = atan2(sqrt(x*x + z*z) , y)*8;
const float phi = atan2(z,x)*8;
const float r2=r*r*r*r;
const float r1=r2*r2;
const float sintheta=r1 * cos(theta);
x = sintheta * cos(phi)+cx;
y = sintheta * sin(phi)+cy;
z = r1 * sin(theta)+cz;

//C transformation, remove this segment for the classic mandelbulb
const float rc = sqrt(cx*cx + cy*cy + cz*cz);
const float theta1 = atan2(sqrt(cx*cx + cz*cz) , cy)*8;
const float phi1 = atan2(cz,cx)*8;
const float sintheta1=rc * cos(theta1);
cx = sintheta1 * cos(phi1);
cy = sintheta1 * sin(phi1);
cz = rc * sin(theta1);

This open some interesting questions:
1. How this looks with a different iteration functions..
2. Can this be used on other fractals..

Here are two examples, sorry for the low quality, but its because I just was making experiments:
The classic mandelbulb
(http://www.rfractals.net/share/CFixed.jpg)


And the variable C (its the same Mandelbulb with the same parameters and the same position):
(http://www.rfractals.net/share/CTransformed.jpg)


If anyone makes a render of this, please let me know, since im interested on the results and also, my renders are not very good.. :)


Title: Re: Iterating C
Post by: eiffie on December 22, 2011, 04:44:16 PM
Very interesting. I will also try rotating C by the original theta and phi as opposed to theta1 and phi1 in your code. I wonder what that will do.


Title: Re: Iterating C
Post by: Aexion on December 22, 2011, 06:07:28 PM
Very interesting. I will also try rotating C by the original theta and phi as opposed to theta1 and phi1 in your code. I wonder what that will do.

Nooo... Do not reverse the angles..  :scared:
It transform from Mr. Happy Cauliflower to..
The Domain of Cthulhu!!
(http://www.rfractals.net/share/The_Domain_of_Cthulhu.jpg)
Its the same area, the same parameters but, with the angles reversed..


Title: Re: Iterating C
Post by: eiffie on December 22, 2011, 06:55:29 PM
I must not understand what you are doing because I get a sphere when using the same power to rotate C. I thought I followed your code??? I do get interesting results when C is rotated to a different power :) and this will be fun to try with other fractals.


Title: Re: Iterating C
Post by: Aexion on December 22, 2011, 07:14:04 PM
I must not understand what you are doing because I get a sphere when using the same power to rotate C. I thought I followed your code??? I do get interesting results when C is rotated to a different power :) and this will be fun to try with other fractals.

Here is my iteration code..
The evil look comes from negative atan2 function in theta1 and phi1..
ps. sorry, no DE..just old plain escapetime
Code:
bool MBulbC(float cx, float cy, float cz,int iter){
float x=cx;
float y=cy;
float z=cz;
unsigned char Counter;
const float rc = sqrt(cx*cx + cy*cy + cz*cz);
for(Counter=0;Counter<iter;Counter++){


//mandelbulb
const float r = sqrt(x*x + y*y + z*z);//radius, used also for escape
const float theta = atan2(sqrt(x*x + z*z) , y)*8;
const float phi = atan2(z,x)*8;
const float r2=r*r*r*r;
const float r1=r2*r2;
const float sintheta=r1 * cos(theta);
x = sintheta * cos(phi)+cx;
y = sintheta * sin(phi)+cy;
z = r1 * sin(theta)+cz;


//c rotation
const float theta1 = -atan2(sqrt(cx*cx + cz*cz) , cy)*8;
const float phi1 = -atan2(cz,cx)*8;
const float sintheta1=rc * cos(theta1);
cx = sintheta1 * cos(phi1);
cy = sintheta1 * sin(phi1);
cz = rc * sin(theta1);


if (r>4) break;

}

if(Counter<iter)
return false;
 else
return true;
}



Title: Re: Iterating C
Post by: Aexion on December 22, 2011, 08:28:39 PM
I must not understand what you are doing because I get a sphere when using the same power to rotate C. I thought I followed your code??? I do get interesting results when C is rotated to a different power :) and this will be fun to try with other fractals.

 :embarrass:
Now I understand why I get some different result: my "version" of the mandelbulb was an experimental one and some of the trigonometric functions are reversed.. also the rotation axis in a different orientation..  ;D
Hence why I get that strange result..
(It often happens to me that I make experiments, and left them over the code.. then reuse the code forgetting the changes.. )
Anyways, try the version that I have posted and you will get the result that I have posted..


Title: Re: Iterating C
Post by: Jesse on December 22, 2011, 08:40:57 PM
Very interesting, mr first class formula supporter!   :D
Will surely try it out!


Title: Re: Iterating C
Post by: DarkBeam on December 22, 2011, 10:25:58 PM
Jesse if you write a formula only write the c rotation like I did for celticmode. and did you include quadrayteansform1 to the last binary? I guess you forgot it?


Title: Re: Iterating C
Post by: Jesse on December 23, 2011, 12:03:46 AM
Jesse if you write a formula only write the c rotation like I did for celticmode. and did you include quadrayteansform1 to the last binary? I guess you forgot it?

I included only the ones in your latest update because you told me to discard older ones.
If you whish me to include it, please put it into your current formula collection for download!

For the c rotation i will have a look into your code, but Aexion's formulas result looks really promising, so i hope i can copy it first.

Cheers


Title: Re: Iterating C
Post by: David Makin on December 23, 2011, 12:19:14 AM
> (It often happens to me that I make experiments, and left them over the code.. then reuse the code forgetting the changes.. )

Common programmer's disease - especially for non-commercial products ;)


Title: Re: Iterating C
Post by: Syntopia on December 23, 2011, 12:25:21 AM
Nice idea, Aexion. Here is few examples I came up with while trying it out.



Title: Re: Iterating C
Post by: Aexion on December 23, 2011, 01:37:16 AM
Very interesting, mr first class formula supporter!   :D
Will surely try it out!
Thanks Jesse!!

> (It often happens to me that I make experiments, and left them over the code.. then reuse the code forgetting the changes.. )

Common programmer's disease - especially for non-commercial products ;)
Tell me that..  ;D



Nice idea, Aexion. Here is few examples I came up with while trying it out.

Beautiful renders!! I like them


A non fixed C perhaps open possibilities, its time to experiment with other fractals and other functions for C..
If anyone found something, please let me know! :)





Title: Re: Iterating C
Post by: DarkBeam on December 23, 2011, 10:15:52 AM
Code:
//Mandelbulb Iteration
const float r = sqrt(x*x + y*y + z*z);
const float theta = atan2(sqrt(x*x + z*z) , y)*8;
const float phi = atan2(z,x)*8;
const float r2=r*r*r*r;
const float r1=r2*r2;
const float sintheta=r1 * cos(theta);
x = sintheta * cos(phi)+cx;
y = sintheta * sin(phi)+cy;
z = r1 * sin(theta)+cz;

//C transformation, remove this segment for the classic mandelbulb
const float rc = sqrt(cx*cx + cy*cy + cz*cz);
const float theta1 = atan2(sqrt(cx*cx + cz*cz) , cy)*8;
const float phi1 = atan2(cz,cx)*8;
const float sintheta1=rc * cos(theta1);
cx = sintheta1 * cos(phi1);
cy = sintheta1 * sin(phi1);
cz = rc * sin(theta1);

Ramiro, thanks for sharing, the 'correct' (original) formulas are;
theta1 = atan2(cy , cx)
phi1 = arcsin(cz/rc)

then do;
// raise rc to a power, but you did not do so. :dink:
multiply angles by some values... then
costh*cosphi = x, cosphi*sinth = y, sinphi = z (multiplying by radius)

theory is here; http://www.fractalforums.com/theory/triplex-algebra/ :)

There is a way to convert that nasty arcsin to atan2. I did this conversion some time ago;

acos(y/sqrt(r)) = 2*atan( sqrt(x*x+z*z) / (r+y) ) = 2* atan2( r+y  , sqrt(x*x+z*z))

for getting the assembly Inigo Quixles bulb. But arcsin is different :fiery:

As it was not enough, my expansion was very wrong!!!

The correct one is simply;

acos(y/sqrt(r)) = atan2(sqrt(x*x+z*z),y)

A shame on me... :embarrass: Now back to work to correct all :help:


Title: Re: Iterating C
Post by: Aexion on December 23, 2011, 10:46:09 AM
Code:
//Mandelbulb Iteration
const float r = sqrt(x*x + y*y + z*z);
const float theta = atan2(sqrt(x*x + z*z) , y)*8;
const float phi = atan2(z,x)*8;
const float r2=r*r*r*r;
const float r1=r2*r2;
const float sintheta=r1 * cos(theta);
x = sintheta * cos(phi)+cx;
y = sintheta * sin(phi)+cy;
z = r1 * sin(theta)+cz;

//C transformation, remove this segment for the classic mandelbulb
const float rc = sqrt(cx*cx + cy*cy + cz*cz);
const float theta1 = atan2(sqrt(cx*cx + cz*cz) , cy)*8;
const float phi1 = atan2(cz,cx)*8;
const float sintheta1=rc * cos(theta1);
cx = sintheta1 * cos(phi1);
cy = sintheta1 * sin(phi1);
cz = rc * sin(theta1);

Ramiro, thanks for sharing, the 'correct' (original) formulas are;
theta1 = atan2(cy , cx)
phi1 = arcsin(cz/rc)

then do;
// raise rc to a power, but you did not do so. :dink:
multiply angles by some values... then
costh*cosphi = x, cosphi*sinth = y, sinphi = z (multiplying by radius)

theory is here; http://www.fractalforums.com/theory/triplex-algebra/ :)

There is a way to convert that nasty arcsin to atan2. I did this conversion some time ago;

acos(y/sqrt(r)) = 2*atan( sqrt(x*x+z*z) / (r+y) ) = 2* atan2( r+y  , sqrt(x*x+z*z))

for getting the assembly Inigo Quixles bulb. But arcsin is different :fiery:

Oh..In chaos, there's no 'correct' formulas.. there's just formulas :)

I do not rise rc to a power because C will change its radius and escape.. the objective of this formulation is to make C orbiting around..


Title: Re: Iterating C
Post by: DarkBeam on December 23, 2011, 11:02:02 AM
Okay let me correct those formulas then I go back 2 you :angel1:


Title: Re: Iterating C
Post by: DarkBeam on December 23, 2011, 12:13:52 PM
Found the right simplification!!! It is;

acos(y/sqrt(r)) = atan2(sqrt(x*x+z*z),y) // used in Inigo Q. bulb
asin(z/sqrt(r)) = 1.5707 - atan2(sqrt(x*x+y*y),z) // used in standard Mandelbulb
Alternative;
asin(z/sqrt(r)) = atan2(z,sqrt(x*x+y*y))


I can do the formula in both flavours, baby. :-*

 :rotfl:

Also found a workaround for arctan() and atan2().

atan(m/n) = atan2(m,n) if n>0. However;
atan(m/n) = atan2(m,abs(n))*sign(n) always


Title: Re: Iterating C
Post by: Aexion on December 23, 2011, 01:46:25 PM
Found the right simplification!!! It is;

acos(y/sqrt(r)) = atan2(sqrt(x*x+z*z),y) // used in Inigo Q. bulb
asin(z/sqrt(r)) = 1.5707 - atan2(sqrt(x*x+y*y),z) // used in standard Mandelbulb


I can do the formula in both flavours, baby. :-*

 :rotfl:

Also found a workaround for arctan() and atan2().

atan(m/n) = atan2(m,n) if n>0. However;
atan(m/n) = atan2(m,abs(n))*sign(n) always


Nice.. here is another experiment: ;D
In the Mandelbox, change the C (cx,cy,cz) for:

Code:

rc=sqrt(cx*cx+cy*cy+cz*cz);

iteration..
const float theta1 = atan2(sqrt(cx*cx + cz*cz) , cy)+0.78539816339744830961566084581988;
const float phi1 = atan2(cz,cx)+0.78539816339744830961566084581988;
const float sintheta1=rc * sin(theta1);
cx = sintheta1 * cos(phi1);
cz = sintheta1 * sin(phi1);
cy = rc * cos(theta1);



Unlike the mandelbulb version, this one add an small angle to the C value every iteration, in this case  pi/4..
There's a big difference between rotating C after or before the Mandelbox transformation. One of them gives to the mandelbox a rotated Rubik Cube look..



Title: Re: Iterating C
Post by: DarkBeam on December 23, 2011, 05:15:07 PM
Keeping in mind that atan, acos, asin are equivalent of atan2 of modified arguments, and considering more untried variations, I am thinking of a very general customizable Mandelbulb formula.

The formula has this form; (user params are bold)
// --- universal Mandelbulb formula ---
// optional; do here abs(x), abs(y), abs(z) to get Benesi-like formulas ... :D

// check for args of th, and load them
// check if atan tweak is ON and modify args accordingly
th := atanmul * power * atan2(args) // Formula with power of angle different than the power of r is not good...
// put tweaks of th here

// check for args of ph, and load them
// check if atan tweak is ON and modify args accordingly
ph := atanmul * zangp * atan2(args)
// put tweaks of ph here
sq_r := sqrt(x*x+y*y+z*z)
r:= sq_r ^ power
x = r*cos(th)*cos(ph) + Cx
y = r*sin(th)*cos(ph) + Cy
z = r*sin(ph)*zmul + Cz



The tweak consists of different choices for the atan2 args.
Let us define the functions
h(a,b) = hypot(a,b) = sqrt(a*a+b*b)
u(a,b) = max(abs(a),abs(b))
d(a,b) = min(abs(a),abs(b))

Tweaks;
a) atan tweak;
The sign of the "signed" (or the first, for variants of type 1) argument is not considered, then atanmul = sgn(argument)
b) xenodream tweak;  (used in the Xenodream variant, after the calculation of atan2() do this correction)
if (angle > 0.5 * M_PI) { angle = M_PI - angle;} else if (angle < -0.5 * M_PI) { ph = -M_PI - angle;}
Args;       
1) x,y // x,z // y,x // y,z // z,x // z,y (normal variables).
2) x, h(y,z) // y, h(x,z) // z, h(x,y) // and the previous args in reversed order. (simulation of arcsin(), arccos() functions).
3) x, u(y,z) // y, u(x,z) // z, u(x,y) // and the previous args in reversed order. (the "cubic distance" instead of the euclidean one).
4) x, d(y,z) // y, d(x,z) // z, d(x,y) // and the previous args in reversed order. (alternate "cubic distance").

This should cover every possible Mandelbulb variation EXCEPT for rotations OR abs(x) thingmajigs.  :dink: (total of 6x4x4 variants for EACH angle considered, WITHOUT considering 4 dimensional bulbs.)


Title: Re: Iterating C
Post by: DarkBeam on December 23, 2011, 10:44:03 PM
I have done the formula but it needs more refinement, see tomorrow :)
From that formula it's straightforward the Aexion C mangling :)


Title: Re: Iterating C
Post by: Jesse on December 23, 2011, 11:30:59 PM
Made some testings, but the possibilities are big, so this needs further exploration.

I guess the first image shows more or less the same as your first result with rotated C, only that you stopped at max iterations and my image was at a certain distance with more iterations at the spikes.  Not really sure but this is one i had those spikes, it was without the negation of the atan2's.

The second (attached) image was an experiment of doing the C rotation based on the difference of the vectors Z and C.
Maybe i did the rotation on C also with a different coordinate system orientation.

A kind of interaction between those vectors seems a not that bad idea to me...?

(http://nocache-nocookies.digitalgott.com/gallery/9/1127_23_12_11_11_18_19.jpeg)



Title: Re: Iterating C
Post by: Aexion on December 24, 2011, 12:40:34 AM
Made some testings, but the possibilities are big, so this needs further exploration.

I guess the first image shows more or less the same as your first result with rotated C, only that you stopped at max iterations and my image was at a certain distance with more iterations at the spikes.  Not really sure but this is one i had those spikes, it was without the negation of the atan2's.

The second (attached) image was an experiment of doing the C rotation based on the difference of the vectors Z and C.
Maybe i did the rotation on C also with a different coordinate system orientation.

A kind of interaction between those vectors seems a not that bad idea to me...?

Beautiful renders Jesse, and you're right, this needs more exploration! :)
And yes, in my first image, I didn't negated the atan2.. It was in the second image on where I negated it (as an experiment suggested by eiffie)

Some sections of the first image reminds me the decoration of the Mayan Stela's, while the second looks like the Brain Coral:
http://en.wikipedia.org/wiki/Brain_coral


ps. Do not mention that the first set looks like the Mayan Calendar in many places, because finding such calendar in a fractal, near 2012 will cause a large amount of end of the world news.. ;D


Title: Re: Iterating C
Post by: Jesse on December 24, 2011, 03:22:08 PM

Beautiful renders Jesse, and you're right, this needs more exploration! :)
And yes, in my first image, I didn't negated the atan2.. It was in the second image on where I negated it (as an experiment suggested by eiffie)

Some sections of the first image reminds me the decoration of the Mayan Stela's, while the second looks like the Brain Coral:
http://en.wikipedia.org/wiki/Brain_coral

The brain coral reminds me of an selforganizating cell automata (dunno if this is a correct name for it) that produces same structures, have to see if i can find the program.

Quote
ps. Do not mention that the first set looks like the Mayan Calendar in many places, because finding such calendar in a fractal, near 2012 will cause a large amount of end of the world news.. ;D

No prob, the Mayan Calendar mythos can be easily falsificated by some bits of information.  :dink:

Merry christmas, attached a test with the amount of C rotation mutliplied by euclidian distance of the vecs...


Title: Re: Iterating C
Post by: Aexion on December 25, 2011, 11:38:52 AM

Merry christmas, attached a test with the amount of C rotation mutliplied by euclidian distance of the vecs...


Merry Christmas for you too Jesse!! Great Render!! The shapes and the lights are incredible! I like it.
One interesting feature hat I have noted, is the fact that if you run C on conditionals, the fractal doesn't show discontinuity, but interesting structures appears..
For example:
Code:
const float theta1 = atan2(sqrt(cx*cx + cz*cz) , cy)*8;
const float phi1 =(x>0)?atan2(cz,cx)*8:-atan2(cz,cx)*8;

Try it.. :)



Title: Re: Iterating C
Post by: DarkBeam on December 25, 2011, 12:07:10 PM
Ramiro this concept is similar to XenoDream's angular fold;

            double rp = pow(r, p);
            double th = atan2(z.y, z.x);
            double ph = acos(z.z / r);
            if (ph > 0.5 * M_PI)
            {
               ph = M_PI - ph;
            }
            else if (ph < -0.5 * M_PI)
            {
               ph = -M_PI - ph;
            }

            z.x = rp * cos(th * p) * sin(ph * p);
            z.y = rp * sin(th * p) * sin(ph * p);
            z.z = rp * cos(ph * p);
            z = z + constant;

            r = z.Length();

 ;D


Title: Re: Iterating C
Post by: DarkBeam on December 25, 2011, 01:25:49 PM
Woohoo!!!! Esto es el RamiroBulb!!!  ;D ;D ;D


Title: Re: Iterating C
Post by: Aexion on December 26, 2011, 02:30:56 AM
Ramiro this concept is similar to XenoDream's angular fold;

            double rp = pow(r, p);
            double th = atan2(z.y, z.x);
            double ph = acos(z.z / r);
            if (ph > 0.5 * M_PI)
            {
               ph = M_PI - ph;
            }
            else if (ph < -0.5 * M_PI)
            {
               ph = -M_PI - ph;
            }

            z.x = rp * cos(th * p) * sin(ph * p);
            z.y = rp * sin(th * p) * sin(ph * p);
            z.z = rp * cos(ph * p);
            z = z + constant;

            r = z.Length();

 ;D


Actually the formulas was for a dynamic rotation of  'C' while iterating, rather for a fixed 'C' iteration...
Here's the function:
Code:
bool MBulbCr(float x, float y, float z,int miter){
int Counter;
float ctx=x;
float cty=y;
float ctz=z;
const float rc = sqrt(ctx*ctx + cty*cty + ctz*ctz);
  for(Counter=0;Counter<miter;Counter++){
const float r = sqrt(x*x + y*y + z*z);
const float theta = atan2(sqrt(x*x + z*z) , y)*8;
const float phi = atan2(z,x)*8;
const float r2=r*r*r*r;
const float r1=r2*r2;
const float sintheta=r1 * cos(theta);
x = sintheta * cos(phi)+ctx;
y = sintheta * sin(phi)+cty;
z = r1 * sin(theta)+ctz;
const float theta1 = atan2(sqrt(ctx*ctx + ctz*ctz) , cty)*8;
const float phi1 =(x>0)?atan2(ctz,ctx)*8:-atan2(ctz,ctx)*8;
const float sintheta1=rc * cos(theta1);
ctx = sintheta1 * cos(phi1);
cty = sintheta1 * sin(phi1);
ctz = rc * sin(theta1);
if (r>4) break;
}
if(Counter<miter)return true;else return false;
}

If you iterate the system with this conditional, it will looks like:

(http://www.rfractals.net/share/Conditional.png)

The field is open for many other combinations of rules (IFS?)..
Good luck!
 


Title: Re: Iterating C
Post by: DarkBeam on December 26, 2011, 07:38:46 PM
Ramiro; your formula, a lot generalized, has been called _GenCWarp and you have been credited :beer:

No time to do test renders now, it may be surely overwhelming btw :scared: :ugly: :headbatting:

Hey a first render ;)

http://www.fractalforums.com/index.php?action=gallery;sa=view;id=9684


Title: Re: Iterating C
Post by: willclark218 on February 09, 2013, 07:43:10 PM
your English is damn good ... better than most Americans.. :embarrass: ... greta post