Logo by bib - 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: Visit the official fractalforums.com Youtube Channel
 
*
Welcome, Guest. Please login or register. April 27, 2024, 06:23:22 AM


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] 2 3   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: Low-hanging dessert: An escape-time donut fractal  (Read 1940 times)
0 Members and 1 Guest are viewing this topic.
msltoe
Iterator
*
Posts: 187


« on: January 21, 2016, 02:27:46 AM »


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;
}


Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #1 on: January 21, 2016, 02:59:46 AM »

mmmmmm... donuts with icing, yummy...
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #2 on: January 21, 2016, 03:02:32 AM »

lol..  nice image. cheesy


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

msltoe
Iterator
*
Posts: 187


« Reply #3 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.
Logged
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #4 on: January 22, 2016, 04:47:04 AM »

cheesy  thanks.
Logged

Buddhi
Fractal Iambus
***
Posts: 895



WWW
« Reply #5 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 ?????
}
Logged

Buddhi
Fractal Iambus
***
Posts: 895



WWW
« Reply #6 on: January 23, 2016, 05:41:41 PM »

I have even easier case. How to define iteration for escape time torus?
Logged

msltoe
Iterator
*
Posts: 187


« Reply #7 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
Logged
Buddhi
Fractal Iambus
***
Posts: 895



WWW
« Reply #8 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.



* donuts.jpg (191.93 KB, 800x600 - viewed 161 times.)
Logged

msltoe
Iterator
*
Posts: 187


« Reply #9 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.
Logged
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #10 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):

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). 
 
« Last Edit: January 23, 2016, 10:32:00 PM by M Benesi » Logged

mclarekin
Fractal Senior
******
Posts: 1739



« Reply #11 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 grin

@ 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.





* donut aaa5 37.jpg (133.83 KB, 520x520 - viewed 153 times.)

* donut aaa8 87.jpg (100.07 KB, 565x580 - viewed 153 times.)
« Last Edit: January 24, 2016, 02:45:59 AM by mclarekin » Logged
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #12 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:



« Last Edit: January 24, 2016, 04:32:15 AM by M Benesi » Logged

msltoe
Iterator
*
Posts: 187


« Reply #13 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.

Logged
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #14 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??


Logged

Pages: [1] 2 3   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Escape-time LRIFS Programming David Makin 11 9247 Last post March 22, 2010, 04:05:57 PM
by kram1032
Kaleidoscopic (escape time) IFS Sierpinski Gasket « 1 2 ... 9 10 » knighty 138 118555 Last post October 28, 2013, 10:23:48 PM
by Clemensson
Is there anything novel left to do in M-like escape-time fractals in 2d? Mandelbrot & Julia Set « 1 2 ... 22 23 » fracmonk 337 80363 Last post May 11, 2017, 10:12:20 PM
by greentexas
Escape time versions of IFS IFS - Iterated Function Systems msltoe 2 13110 Last post April 18, 2011, 02:54:48 PM
by msltoe
Improving over the escape time map (new) Theories & Research megafiddle 1 1260 Last post November 22, 2013, 03:38:37 AM
by megafiddle

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