Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => (new) Theories & Research => Topic started by: msltoe on January 21, 2016, 02:27:46 AM




Title: Low-hanging dessert: An escape-time donut fractal
Post by: msltoe on January 21, 2016, 02:27:46 AM
(http://nocache-nocookies.digitalgott.com/gallery/18/803_21_01_16_2_22_34.png)
Inner loop for this fractal:
Code:
 double rad1 = 1.0;
 double rad2 = 0.2;
 double nSect = 2*pi/9;
 double fact = 3;

 norm = x*x+y*y+z*z;
 while ((norm<16)&&(iter<imax)) {

   (*nfunc)++;

   r1 = x*x + y*y;
   flag = 0;
   if (r1 < (rad1+rad2)*(rad1+rad2)) {
    r = sqrt(r1);

    c1 = rad1 * x/r;
    s1 = rad1 * y/r;

    x1 = (x - c1);
    y1 = (y - s1);
    z1 = z;

    r2 = x1*x1+y1*y1+z1*z1;
    if (r2 < rad2*rad2) {
     //maxnorm = (iter % 5); maxnorm /= 4.0;iter=imax+1;
     maxnorm = (theta2 + pi) / (2.0*pi) ;iter=imax+1;
     flag = 1;
    }
   }

   if (!flag) {

    theta = atan2(y,x);
    theta2 = nSect * round (theta / nSect);

    c1 = cos(theta2);
    s1 = sin(theta2);

    x1 = c1 * x + s1 * y;
    y1 = -s1 * x + c1 * y;
    z1 = z;

    x1 = x1 - rad1;

    x=fact*x1;y=fact*z1;z=fact*y1;

   }
   norm = x*x+y*y + z*z;
}




Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: 3dickulus on January 21, 2016, 02:59:46 AM
mmmmmm... donuts with icing, yummy...


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 21, 2016, 03:02:32 AM
lol..  nice image. :D


  Theta2 declaration order.  <-compiler error in my brain.


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: msltoe on January 21, 2016, 03:31:40 AM
M Benesi: theta2 - set before the loop to anything you want for the color of the main donut. The declaration was above where I clipped. If my program could vary more than hue, I would have chosen brown for chocolate.


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 22, 2016, 04:47:04 AM
:D  thanks.


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: Buddhi on January 23, 2016, 05:15:23 PM
I'm trying to get good distance estimation with deltaDE algorithm which we can use for all IFS-like fractals. It works well outside the torus, but the problem is inside. In this formula iteration vector is not calculated when r2 < rad2. It makes discontinuity of iteration vector value, so surface normal vector cannot be calculated properly.
I have cleaned up your code and removed all unnecessary conditions. It works exactly the same like your formula. It's only code for iteration (no loops and escape condition)
My question is what should be after 'else' statement. When it's empty we can get donuts but DE fails. There should be something here.

Code:
        double rad1 = 1.0;
double rad2 = 0.1;
double nSect = 2 * M_PI / 4;
double fact = 3;
double theta2 = 0.0;

double r = sqrt(z.x * z.x + z.y * z.y);

double c1 = rad1 * z.x / r;
double s1 = rad1 * z.y / r;

CVector3 z1 = CVector3(z.x - c1, z.y - s1, z.z);

double r2 = z1.Length();

if (r2 > rad2)
{

double theta = atan2(z.y, z.x);
theta2 = nSect * round(theta / nSect);

double c1 = cos(theta2);
double s1 = sin(theta2);

double x1 = c1 * z.x + s1 * z.y;
double y1 = -s1 * z.x + c1 * z.y;
double z1 = z.z;

x1 = x1 - rad1;

z.x = fact * x1;
z.y = fact * z1;
z.z = fact * y1;
}
else
{
?????  WHAT SHOULD BE HERE ?????
}


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: Buddhi on January 23, 2016, 05:41:41 PM
I have even easier case. How to define iteration for escape time torus?


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: msltoe on January 23, 2016, 07:07:47 PM
Buddhi,

 Since I use a simple and slow DE in my test code, I probably am not encountering what you encounter.

 While I don't completely understand your question, I'll explain my code:

 The first "if" statement is checking for the condition whether we're inside a solid donut. If so, we're done and we just need to color it.
 
 The second "if" statement which conditions on that we didn't hit the solid donut, does the transformation so that the next iteration
 could be a solid donut in one of the segments around the current iteration's donut.

 I use the "solid donut" trick, which is not typical of escape-time fractals, to so that we don't end up with a vanishing fractal as max iteration number is increased.

 Hope that helps.

-michael


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: Buddhi on January 23, 2016, 07:12:09 PM
I have found something. I have started from torus equation:

Code:
	double R = sqrt(z.x * z.x + z.y * z.y);
double R2 = rad1 - R;
double t = R2 * R2 + z.z * z.z - rad2 * rad2;

Then quite good torus iteration is:

Code:
double R = sqrt(z.x * z.x + z.y * z.y);
double R2 = rad1 - R;
double t = R2 * R2 + z.z * z.z - rad2 * rad2;
if (t < 0.03)
{
   z /= t;
}

Finally donut formula is:

Code:
	
        double rad1 = 1.0;
double rad2 = 0.1;
double nSect = 2 * M_PI / 9;
double fact = 3;
double theta2 = 0.0;

double R = sqrt(z.x * z.x + z.y * z.y);
double R2 = rad1 - R;
double t = R2 * R2 + z.z * z.z - rad2 * rad2;

if (t > 0.03)
{
double theta = atan2(z.y, z.x);
theta2 = nSect * round(theta / nSect);

double c1 = cos(theta2);
double s1 = sin(theta2);

double x1 = c1 * z.x + s1 * z.y;
double y1 = -s1 * z.x + c1 * z.y;
double z1 = z.z;

x1 = x1 - rad1;

z.x = fact * x1;
z.y = fact * z1;
z.z = fact * y1;
}
else
{
z /= t;
}

It's still not perfect, but works much better with deltaDE distance estimation and gives better normal vector calculation.



Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: msltoe on January 23, 2016, 07:22:22 PM
Buddhi: Thanks a million for trying out this fractal. My program slows down considerably when I try to zoom-in.


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 23, 2016, 07:53:10 PM
Awesome work Buddhi!  Nice reflections.  

  I'll try and figure it out, but my implementation of your code is skipping donuts (it's all due to the smaller radius check):
(https://lh3.googleusercontent.com/-uFkFmdWj7Wo/VqPxF-CGYHI/AAAAAAAAEqc/yaf_xWy7Bcc/s400-Ic42/test.jpg)
Code:
uniform float BigRadius; slider[-10,1.,10]
float rad1=BigRadius;

uniform float SmallRadius; slider[-10,.1,10]
float rad2=SmallRadius*SmallRadius;    //only use rad2*rad2 soo.....

uniform float DonutFactor; slider[-10,3.,10]

uniform int Donuts;slider[1,9,20]
float nSect=6.283/float(Donuts);


void donut(inout vec3 z, inout float dr) {


float R = sqrt(z.x * z.x + z.y * z.y);
float R2 = rad1 - R;
float t = R2 * R2 + z.z * z.z - rad2;  //rad2= SmallRadius^2

if (t > 0.)   //.03 isn't as nice looking???  and it will usually be greater than zero, right?? 
{
float theta = atan(z.y, z.x)/nSect;
if (theta>-.5) {theta= floor (theta+.5);
} else { theta= ceil(theta-.5);}
theta = nSect * theta;

float c1 = cos(theta);
float s1 = sin(theta);

float x1 = c1 * z.x + s1 * z.y;
float y1 = -s1 * z.x + c1 * z.y;
float z1 = z.z;

x1 = x1 - rad1;

z.x = DonutFactor * x1;
z.y = DonutFactor * z1;
z.z = DonutFactor * y1;
dr=dr*(DonutFactor);
}
else if (t!=0.)
{
z /= t;   
}

}

  DE return is .5*r/dr (without the .5, I get nothing). 
 


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: mclarekin on January 24, 2016, 02:29:30 AM
@ msltoe
Quote
While I don't completely understand your question,
  So it is not only me LOL. Though I think Buddhi has more problems understanding me, as I only half know what I am doing and I make some weird assumptions ;D

@ M.Benesi.  A quick play and I find DE, the Linear deltaDE method, is quite fragile with this formula (and can be slow)

@msltoe BTW,  this formula of yours is real nice  //http://www.fractalforums.com/theory/choosing-the-squaring-formula-by-location/30/ reply 39.Slower than the other ones, but more interesting and shaper image.
I added   your tweaks to it as well :

double zs3 = (zs.x + zs.y + zs.z) + scale1 * zs.y  * zs.z; // tweaking the squares

  z1.y = (2 * z.x * z.y)* zsd * scale2;// scaling y

It is currently called  MsltoeSym3Mod3 in Mandelbulber, you can rename it if you prefer something else.





Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 24, 2016, 03:25:05 AM
@ M.Benesi.  A quick play and I find DE, the Linear deltaDE method, is quite fragile with this formula (and can be slow)
 Yes, and apparently you got it to work.  Thanks for the help.   :fiery:

  I'll go over msltoe's math, for now, it works if I do 4 sections???  If we vary a few of the radii, we get interesting loopy fractals reminiscent of other IFS:


(https://lh3.googleusercontent.com/-3XLI0uir1FY/VqRCNAx8zJI/AAAAAAAAErE/QJpxZiSHoyg/s640-Ic42/test-2.jpg)


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: msltoe on January 24, 2016, 03:28:51 AM
M Benesi: Your rendition is really fascinating with the missing inner donut that the eye almost fills in if you stare at it enough.
mclarekin: Your first pic is definitely the most fattening of the bunch. Also, it demonstrates what happens when you choose radii that cause the donuts to overlap. BTW, thanks for your compliment and implementation of my juliabulb formulas. I never could figure out how to symmetrize complex Julia seeds.



Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 24, 2016, 05:07:15 AM
  I'm curious as to why what I am doing works fine for nSect= 2pi/4 but not for any others??

(https://lh3.googleusercontent.com/-KRdNV2r36oI/VqRNP2bbnLI/AAAAAAAAErQ/l_imYSSbdlM/s640-Ic42/test-4.jpg)


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: mclarekin on January 24, 2016, 05:21:49 AM
@ M.Benesi. I think it is just Buddhi's standard deltaDE linear which I have yet to study and figure  out (as it is hidden away in part of the code where I never venture). Whereas the analytic methods are upfront and easier to understand. I generally just sit back and let Buddhi sort out anything that is not a mbox or mbulb.  What I mean by fragile is that I tried a quick few hybrids, and generally the DE calc goes bad if I stray too much away from the original formula (not as robust as T1 PT.)

Your image looks cool!!

@ msltoe.  Yes, I have finally finished with your juliabulbs ( but I cannot get effie's versions to work well, it has strange cuts in it.)   Those juliabulbs are really good with analytic log DE, I seldom have to adjust the raymarching step from the default 1.0.  On the UI's i have added  rotation and  symmetrical addCpixel options (code attached) . Now it is time for me to go back and finish  Reimann spheres

Cheers guys :)

Code:
  if (fractal->transformCommon.rotationEnabled)
  {
    z = fractal->transformCommon.rotationMatrix.RotateVector(z);
  }

  if (fractal->transformCommon.addCpixelEnabledFalse)
  {
    CVector3 tempFAB = c;
    if (fractal->transformCommon.functionEnabledx)
    {
            tempFAB.x = fabs(tempFAB.x);
    }
    if (fractal->transformCommon.functionEnabledy)
    {
            tempFAB.y = fabs(tempFAB.y);
    }
    if (fractal->transformCommon.functionEnabledz)
    {
            tempFAB.z = fabs(tempFAB.z);
    }
    tempFAB *= fractal->transformCommon.constantMultiplier000;
    if (z.x > 0) z.x += tempFAB.x;
    else z.x -= tempFAB.x;
    if (z.y > 0) z.y += tempFAB.y;
    else z.y -= tempFAB.y;
    if (z.z > 0) z.z += tempFAB.z;
    else z.z -= tempFAB.z;
  }
}


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: mclarekin on January 24, 2016, 05:32:35 AM
Have you tried doing an exact copy of Buddhi's code?

I see some differences although for all I know mathematically they could be the same

atan(z.y, z.x)/nSect;  would crash in C++, must be either atan2(z.y, z.x) or atan(z.y/z.x)

have you changed your code from what you previously posted?


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 24, 2016, 06:13:30 AM
Yeah (as exact of a copy as I could- I actually had to alter it a bit to get the donuts for nSect=2pi/4... so something is wrong).  I'll take a gander at your code above after I get this one idea tested (thanks!).  It's starting to resemble something I recall... probably something msltoe did in the past.  :D

(https://lh3.googleusercontent.com/-M_BW7VQKcpE/VqRbLOxHUVI/AAAAAAAAEro/GPSQPQaIBwA/s400-Ic42/test-6.jpg)(https://lh3.googleusercontent.com/-ZETlDZm93Ts/VqRbMAi8OBI/AAAAAAAAEr0/0haP491QJ0w/s400-Ic42/test-7.jpg) (https://lh3.googleusercontent.com/-ZETlDZm93Ts/VqRbMAi8OBI/AAAAAAAAEr0/0haP491QJ0w/s0-Ic42/test-7.jpg)(https://lh3.googleusercontent.com/-TLNhIw0A2IA/VqRbM5o-ObI/AAAAAAAAEsA/cjex05YRo9s/s400-Ic42/test-8.jpg) (https://lh3.googleusercontent.com/-TLNhIw0A2IA/VqRbM5o-ObI/AAAAAAAAEsA/cjex05YRo9s/s0-Ic42/test-8.jpg)(https://lh3.googleusercontent.com/-70NAOGXV8n4/VqRieSmgkaI/AAAAAAAAEsY/8DyTXT-19u0/s400-Ic42/test-10.jpg) (https://lh3.googleusercontent.com/-70NAOGXV8n4/VqRieSmgkaI/AAAAAAAAEsY/8DyTXT-19u0/s0-Ic42/test-10.jpg)(https://lh3.googleusercontent.com/-SUn_r4aRblM/VqRieEsj11I/AAAAAAAAEsU/FKPpFW7PCQg/s400-Ic42/test-9.jpg) (https://lh3.googleusercontent.com/-SUn_r4aRblM/VqRieEsj11I/AAAAAAAAEsU/FKPpFW7PCQg/s0-Ic42/test-9.jpg)

  I can't remember who introduced that type of pseudo-fractal here?   :embarrass:   Must be what msltoe meant by a low hanging dessert- a formula you can make an easy mistake on and do something quite cool.


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: mclarekin on January 24, 2016, 09:21:57 AM
cool weird place, yes it can be productive making mistakes ;D



 float theta = atan(z.y, z.x)/nSect; ---------------------------atan2?

                if (theta>-.5) {theta= floor (theta+.5);
                } else { theta= ceil(theta-.5);} -----------------------------------is this if() really giving you the same answer as "round" ?
                theta = nSect * theta;


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: Buddhi on January 24, 2016, 09:54:46 AM
Awesome work Buddhi!  Nice reflections.  

  I'll try and figure it out, but my implementation of your code is skipping donuts (it's all due to the smaller radius check):
(https://lh3.googleusercontent.com/-uFkFmdWj7Wo/VqPxF-CGYHI/AAAAAAAAEqc/yaf_xWy7Bcc/s400-Ic42/test.jpg)
Code:
uniform float BigRadius; slider[-10,1.,10]
float rad1=BigRadius;

uniform float SmallRadius; slider[-10,.1,10]
float rad2=SmallRadius*SmallRadius;    //only use rad2*rad2 soo.....

uniform float DonutFactor; slider[-10,3.,10]

uniform int Donuts;slider[1,9,20]
float nSect=6.283/float(Donuts);


void donut(inout vec3 z, inout float dr) {


float R = sqrt(z.x * z.x + z.y * z.y);
float R2 = rad1 - R;
float t = R2 * R2 + z.z * z.z - rad2;  //rad2= SmallRadius^2

if (t > 0.)   //.03 isn't as nice looking???  and it will usually be greater than zero, right?? 
{
float theta = atan(z.y, z.x)/nSect;
if (theta>-.5) {theta= floor (theta+.5);
} else { theta= ceil(theta-.5);}
theta = nSect * theta;

float c1 = cos(theta);
float s1 = sin(theta);

float x1 = c1 * z.x + s1 * z.y;
float y1 = -s1 * z.x + c1 * z.y;
float z1 = z.z;

x1 = x1 - rad1;

z.x = DonutFactor * x1;
z.y = DonutFactor * z1;
z.z = DonutFactor * y1;
dr=dr*(DonutFactor);
}
else if (t!=0.)
{
z /= t;   
}

}

  DE return is .5*r/dr (without the .5, I get nothing). 
 

In your code you have reduced wall thickness of torus to 0 by changing
Code:
if (t > 0.03) 
to
Code:
if (t > 0.00) 

This torus formula which I created  just from torus equation, works a little weird. It gives repeated torus as shown on picture torus1.jpg. We need only this one particular torus which comes directly from torus equation. We can cut it using condition:
Code:
if (t > 0.03) 

If we just play with torus formula with following code:
Code:
		
double rad2 = fractal->donut.ringThickness;
double R = sqrt(z.x * z.x + z.y * z.y);
double R2 = fractal->donut.ringRadius - R;
double t = R2 * R2 + z.z * z.z - rad2 * rad2;
if(t > 0.03)
{
z *= 2.0;
}
else
{
z /= t;
}

we can get toruses like on image torus2.jpg. We see series of toruses generated by z *= 2.0. (normally we used here msltoe code for donut iterations)

But if we change code to have
Code:
if (t > 0.0)
Then wall thickness of torus is exactly zero, so can be invisible or distorted like on image torus3.jpg

Probably we need some better formula to generate escape time toruses.


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: Buddhi on January 24, 2016, 10:04:47 AM
Yeah (as exact of a copy as I could- I actually had to alter it a bit to get the donuts for nSect=2pi/4... so something is wrong).  I'll take a gander at your code above after I get this one idea tested (thanks!).  It's starting to resemble something I recall... probably something msltoe did in the past.  :D

  I can't remember who introduced that type of pseudo-fractal here?   :embarrass:   Must be what msltoe meant by a low hanging dessert- a formula you can make an easy mistake on and do something quite cool.

Do you remember this mistake and can you show us your code? These shapes are very interesting.


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: Buddhi on January 24, 2016, 10:09:55 AM
  I'm curious as to why what I am doing works fine for nSect= 2pi/4 but not for any others??

(https://lh3.googleusercontent.com/-KRdNV2r36oI/VqRNP2bbnLI/AAAAAAAAErQ/l_imYSSbdlM/s640-Ic42/test-4.jpg)


I' curious how you get it working with DE calculated from formula. I see that you only use: dr=dr*(DonutFactor)
The reason why I use deltaDE algorithm is unknown way to calculate proper dr especially for torus. DeltaDE uses deltas to calculate dr, so it's much slower, but works well in most of cases.


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 24, 2016, 08:42:38 PM
Do you remember this mistake and can you show us your code? These shapes are very interesting.
  Is mistake the word we should be using?  :D
Code:
void donut(inout vec3 z, inout float dr, inout bool donutcheck) {

float c1; float s1;float t;
float R = sqrt(z.x * z.x + z.y * z.y);

if (test1) {  // radius check variable t=  msltoe's original radius check formula

c1 = z.x- rad1 * z.x / R; //rad1= Large Radius (of alleged tori)
s1 = z.y- rad1 * z.y / R;
c1*=c1;
s1*=s1;
t=sqrt(c1+s1+z.z*z.z);

} else {  // t = Buddhi's radius check

float R2 = rad1 - R;
t = abs(R2 * R2 + z.z * z.z - rad2);  //rad2= SmallRadius^2
}

// I used the smaller radius to check t
// instead of using SmallerRadius^2 * DonutFactor (.03 for original formula)

if (t > SmallRadius)  {
float theta = atan(z.y, z.x)/nSect;     //check if we are in specific section of donut

if (theta>-.5) { theta= floor (theta+.5);}     //same as rounding theta
  else   { theta=  ceil  (theta-.5);}    // same as rounding theta

theta = nSect * theta;

float c1 = cos(theta);
float s1 = sin(theta);

float x1 = c1 * z.x + s1 * z.y;
float y1 = -s1 * z.x + c1 * z.y;
float z1 = z.z;

x1 = x1 - rad1;

z.x = DonutFactor * x1;
z.y = DonutFactor * z1;
z.z = DonutFactor * y1;
dr=dr*(DonutFactor);
}
else if (t!=0.)
{

z *= t;      // yes... *=  not /=     I don't get a lot of hits for /=???

  }

}

// different DEs!:

if (returnmode==1) {
return 0.5*log(r)*r/dr;    // used Mandelbulb frag as a template... lazy :D


} else if (returnmode==4) {
return .5*sqrt(z.x*z.x+z.y*z.y)/dr/DonutFactor;   // works nice with smaller radius = 0
} else if (returnmode==3) {
return sqrt(z.x*z.x+z.z*z.z)/dr/DonutFactor*.5;   // works nice with smaller radius = 0
} else if (returnmode==2) {
return sqrt(z.y*z.y+z.z*z.z)/dr/DonutFactor*.5;   // works nice with smaller radius = 0
} else if (returnmode==5) {
return abs(z.x)/dr/DonutFactor*.5;   
} else if (returnmode==6) {
return abs(z.y)/dr/DonutFactor*.5;
} else if (returnmode==7) {
return abs(z.z)/dr/DonutFactor*.5;
} else if (returnmode==8) {
return .5*r/dr/DonutFactor;
}


  Primary differences?  

1) The torus's smaller radius is used for the radius check
2) if radius check is not passed,  z*=t instead of z/=t (I don't get nice images for z/=t???)
3) different DE (yeah.... that's important!  You get something that resembles Cantor Dust instead of polygonals if you use standard DE)!
4) test1 boolean switch makes it so the SmallerRadius has less of an effect:  (test1 + ~20*SmallerRadius) ~~ (!test1 + SmallerRadius). 

  Use:

1)  start out with smaller radius set to 0
2)  returnMode (should be called DE_Mode) = 2, 3, or 4  to check out the polygonals- you'll get dust if you set smaller radius to 0 for regular DE
3)  Donuts = 4 is a nice one (it does the square shapes)
4)  DonutFactor 1.1~1.3



Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 24, 2016, 09:11:53 PM
I' curious how you get it working with DE calculated from formula. I see that you only use: dr=dr*(DonutFactor) The reason why I use deltaDE algorithm is unknown way to calculate proper dr especially for torus. DeltaDE uses deltas to calculate dr, so it's much slower, but works well in most of cases.

  dr is the scaling factor in this case, and the rest of it is in my post above:  I changed DE because of the way the variables are manipulated in the fractal, and it created nice results.


  side note:  I'm not positive as to what deltaDE is, is it an average DE from points around the center of where we want our DE, or the lowest DE from points within delta of the point we want DE from?



  I've got a vague recollection of where I saw those spider web things- a recent Bond movie?? 


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 24, 2016, 11:45:22 PM
  I wrote a frag for you to play with (or look at and translate code to Mandelbulber 2 in mclarekin and/or Buddhi's case).  It's attached, along with the ray-tracer I use for colors.  You need to download your own coloring textures (check the coloring thread in the Fragmentarium section for a few links) to use with it, if you're using Fragmentarium.  

  You also might want to update to the latest version of Fragmentarium, because this frag includes feedback.  

  Rotating around the x-axis by pi/2 (90 degrees) during different iterations gives interesting results (with proper return-mode set).  These aren't the coolest... just a couple to show potential:
(https://lh3.googleusercontent.com/-TW9ZppQSmck/VqVSPhsdq-I/AAAAAAAAEs0/6NKOHXn1lFk/s400-Ic42/test-2.jpg)(https://lh3.googleusercontent.com/-tQRfwKAzahM/VqVSQ2BVxnI/AAAAAAAAEtE/yHruVYjhaWY/s400-Ic42/test-3.jpg)(https://lh3.googleusercontent.com/-CVL3gRZBRD0/VqVSQcgDRhI/AAAAAAAAEs8/SKjy_LywzQw/s400-Ic42/test-4.jpg)

  
  If you don't have the latest version of fragmentarium with feedback, use Donut_no_Feedback.frag.

  If you are using the latest version, it might crash if you use the Donut_no_Feedback.frag, so use the Donut.frag!!!!

  Updated Donut frag later in thread...  Donut no feedback is not updated!!!!!


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: mclarekin on January 25, 2016, 12:31:28 AM
singing

"M.Benesi,
he's our man
If anyone can do it
BenesiMan can!"

zappa powah to the people :D :D :D

They look like the magma snow crystal from planet nine

Well done Matt


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 25, 2016, 12:37:44 AM
Graeme!!  

  That was a broken version!!  Just updated and replaced Donut.frag, if you got it before I updated, that version is REAAALLLLYY slow (because I removed a cutoff statement).

  So.. I made 2 versions, no_Feedback (for old Fragmentarium versions), and regular (with the cutoff) for newer versions.  


  Man.. I hope you see this before you try it out.  It is SOOOOO slow.   :embarrass:


  ohh, and thanks.  :D


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: mclarekin on January 25, 2016, 12:44:51 AM
no sweat

i am hoping Buddhi will code this one.  I need to time travel back to 2010/11 and finish the riemann spheres

cheers


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 25, 2016, 12:47:31 AM
i am hoping Buddhi will code this one.
 :D  Me too.  I was wondering where and how to code the DE and dr calculations in Mandelbulber 2...  I'm thinking these alternative DE's might be good for a Menger.

(https://lh3.googleusercontent.com/-j0WRGzLrOB4/VqVhtCvjv5I/AAAAAAAAEts/TcT_dz5CR_E/s400-Ic42/test-2.jpg) (https://lh3.googleusercontent.com/-j0WRGzLrOB4/VqVhtCvjv5I/AAAAAAAAEts/TcT_dz5CR_E/s0-Ic42/test-2.jpg)(https://lh3.googleusercontent.com/-I0I-j6KsptI/VqVhsTKN1BI/AAAAAAAAEtg/sgE06qyIojc/s400-Ic42/test-3.jpg) (https://lh3.googleusercontent.com/-I0I-j6KsptI/VqVhsTKN1BI/AAAAAAAAEtg/sgE06qyIojc/s0-Ic42/test-3.jpg)


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: msltoe on January 25, 2016, 04:27:21 AM
Great job Matt on turning donuts into superstring ornaments suitable for 3-D printing.


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 25, 2016, 07:33:11 AM
 Thanks msltoe, you sort of put it on a tee for us to swing at. 

https://www.youtube.com/watch?v=p3F1eyCor-U (https://www.youtube.com/watch?v=p3F1eyCor-U)


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: 3dickulus on January 25, 2016, 08:06:07 AM
really interesting to watch the evolution of a formula.

@MB if you can find time, can you put together a zip of the frags you would like in the Examples/MBenesi folder for Fragmentarium? I think the collection I have may be out of sync with the stuff you are working with and has mostly beta versions.

btw, nice work guys!  :beer:


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 25, 2016, 08:42:01 AM
k, tomorrow that will be my project (organize and document frags).  Still have to add stellation/ polygonization/polyhedronization to this one.  Might be neat- or maybe just very nSect by iteration?  <<--- that might work too.  Tomorrow.  

  I didn't get around to the working on the newer computer yet.. because... mmmmhh donut.  

  Ohh, and... I decided to throw a Menger in on some iterations, and.. well, wow.
(https://lh3.googleusercontent.com/-SkNhUiLz-Eo/VqXPeDhYuII/AAAAAAAAEuk/koT5KbpeNxA/s400-Ic42/wow.jpg)(https://lh3.googleusercontent.com/-PaG_h5t_nNU/VqXPdeYPppI/AAAAAAAAEuY/YxTb-pvp2tY/s400-Ic42/wow-3.jpg) (https://lh3.googleusercontent.com/-PaG_h5t_nNU/VqXPdeYPppI/AAAAAAAAEuY/YxTb-pvp2tY/s800-Ic42/wow-3.jpg)

  And then I thought.. .why not T1 too (just added a T1 to one of those Menger's from above):
(https://lh3.googleusercontent.com/-F8XHgle9YYg/VqXPdiTu2uI/AAAAAAAAEug/rgaV_1q1_0Q/s400-Ic42/wow-4.jpg) (https://lh3.googleusercontent.com/-F8XHgle9YYg/VqXPdiTu2uI/AAAAAAAAEug/rgaV_1q1_0Q/s800-Ic42/wow-4.jpg)

  Attached is the latest... It's a feedback version, so you need 3Dickulus's latest version of Fragmentarium if you want to use it, at least until I edit out the feedback part.  Or you do.  :D

  It has iterations for rotations, for T1, and for Menger (instead of Donut).  I didn't do Menger on the same iteration as Donuts in this frag.. probably should.  So... yeah.  I'll get on that, unless someone else does.  I'm including the raytracer here, look in the Fragmentarium coloring thread for a couple of links to some textures to use for coloring.



Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: 3dickulus on January 25, 2016, 02:50:42 PM
 O0 take your time man, I hate being interrupted when I'm enjoying a good snack 88)
mmmmm... honey glazed!
Thanks for sharing!


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 25, 2016, 06:21:05 PM
float theta = atan(z.y, z.x)/nSect; ---------------------------atan2?
  In Fragmentarium, atan() = atan2();   //  <-- functuation- it's when programmers end statements in;   
// omg... that's an absolutely horrible pun. 

Quote
                if (theta>-.5) {theta= floor (theta+.5);
                } else { theta= ceil(theta-.5);} -----------------------------------is this if() really giving you the same answer as "round" ?

  floor() gives you the closest integer equal to or less than your input value.  So if you are -.5 and above, if you add in .5, you're doing the same thing as rounding:

floor (1.3 +.5) = round (1.3) = 1   
floor (1.6 +.5) = round (1.6) = 2   // we set the rounding cutoff with .5... can be something else if we want

 once you hit -.5:

floor (-.5 +.5) =  0     !=   round (-.5) = -1

So you switch to the ceiling function (which gives you the nearest integer greater than or equal to your input value) and subtract -.5 instead:

ceil (-1.4 -.5) = ceil (-1.9) = round (-1.4) =  -1
ceil (-2.7 -.5) = ceil (-3.2) = round (-2.7) =  -3

If we added .5 instead of subtracting it:

ceil (-1.4 +.5) = ceil (-.9) =0    !=  round (-1.4) = -1


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: Buddhi on January 25, 2016, 08:13:25 PM
  Is mistake the word we should be using?  :D

  Primary differences?  

1) The torus's smaller radius is used for the radius check
2) if radius check is not passed,  z*=t instead of z/=t (I don't get nice images for z/=t???)
3) different DE (yeah.... that's important!  You get something that resembles Cantor Dust instead of polygonals if you use standard DE)!
4) test1 boolean switch makes it so the SmallerRadius has less of an effect:  (test1 + ~20*SmallerRadius) ~~ (!test1 + SmallerRadius). 

  Use:

1)  start out with smaller radius set to 0
2)  returnMode (should be called DE_Mode) = 2, 3, or 4  to check out the polygonals- you'll get dust if you set smaller radius to 0 for regular DE
3)  Donuts = 4 is a nice one (it does the square shapes)
4)  DonutFactor 1.1~1.3



I started to play with your different DE modes. It's amazing how it works. It looks like shapes are not coming from fractal formula but just from errors of distance estimation.
E.g. I got something like on attached image:

With DE calculation built into formula I can't get more than 4 donuts, too. I also had to change from z/=t to z*=t

So the only way to get different number of donuts (not weird shapes) is to use deltaDE algorithm.

You asked how deltaDE works so here is algorithm (pseudocode is better for explanation):

Code:
vect3 z0 = ResultOfFractalIterations(z)
float r = length(z0)

vect3 z1 = ResultOfFractalIterations(z + vect3(delta, 0,0))
float r1 = length(z1)
float dr1 = fabs(r1 - r) / delta

vect3 z2 = ResultOfFractalIterations(z + vect3(0, delta, 0))
float r2 = length(z2)
float dr2 = fabs(r2 - r) / delta

vect3 z1 = ResultOfFractalIterations(z + vect3(0, 0, delta))
float r3 = length(z3)
float dr3 = fabs(r3 - r) / delta

double dr = sqrt(dr1*dr1 + dr2*dr2 + dr3*dr3)

distance = 0.5 * r / dr  (or distance = 0.5 * r * log(r) / dr for mandelbulbs)

One important remark thing is to calculate z1, z2 and z3 using exactly the same number of iterations as z0
delta must be some very small number. For doubles I use 1e-10. For floats the best is something about 1e-5.

Inside fractal formula we don't need to calculate dr.


Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: M Benesi on January 25, 2016, 11:36:40 PM
Quote
So the only way to get different number of donuts (not weird shapes) is to use deltaDE algorithm.
 What happens when you do DeltaDE combined with the modified DE I introduced?  

Quote
You asked how deltaDE works so here is algorithm (pseudocode is better for explanation):

Code:
vect3 z0 = ResultOfFractalIterations(z)
float r = length(z0)

vect3 z1 = ResultOfFractalIterations(z + vect3(delta, 0,0))
float r1 = length(z1)
float dr1 = fabs(r1 - r) / delta

vect3 z2 = ResultOfFractalIterations(z + vect3(0, delta, 0))
float r2 = length(z2)
float dr2 = fabs(r2 - r) / delta

vect3 z1 = ResultOfFractalIterations(z + vect3(0, 0, delta))
float r3 = length(z3)
float dr3 = fabs(r3 - r) / delta

double dr = sqrt(dr1*dr1 + dr2*dr2 + dr3*dr3)

distance = 0.5 * r / dr  (or distance = 0.5 * r * log(r) / dr for mandelbulbs)

One important remark thing is to calculate z1, z2 and z3 using exactly the same number of iterations as z0
delta must be some very small number. For doubles I use 1e-10. For floats the best is something about 1e-5.

Inside fractal formula we don't need to calculate dr.
 Thanks for the explanation!  That helps a lot.  Quick question:  do you +/- delta, or only add delta?  

  Also, did you ever try skipping delta DE until you get closer to the fractal?  




Title: Re: Low-hanging dessert: An escape-time donut fractal
Post by: mclarekin on January 26, 2016, 08:16:53 AM
@M.Benesi, thanks for explanations. As we all know, I need as much help as I can get. ;D

Quote
  What happens when you do DeltaDE combined with the modified DE I introduced?
I have been thinking more work is needed in this area..  It is frustrating when you cannot get a good render of a real interesting fractal.

@Buddhi.  Thanks for the information, and it's good to see you being active at the forums, sharing your knowledge :) :) :)