msltoe
Iterator
Posts: 187
|
|
« on: January 21, 2016, 02:27:46 AM » |
|
Inner loop for this fractal: 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
|
|
« Reply #1 on: January 21, 2016, 02:59:46 AM » |
|
mmmmmm... donuts with icing, yummy...
|
|
|
Logged
|
|
|
|
M Benesi
|
|
« Reply #2 on: January 21, 2016, 03:02:32 AM » |
|
lol.. nice image. 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
|
|
« Reply #4 on: January 22, 2016, 04:47:04 AM » |
|
thanks.
|
|
|
Logged
|
|
|
|
Buddhi
|
|
« 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. 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
|
|
« 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
|
|
« Reply #8 on: January 23, 2016, 07:12:09 PM » |
|
I have found something. I have started from torus equation: 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: 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: 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.
|
|
|
|
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
|
|
« 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): 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
|
|
« Reply #11 on: January 24, 2016, 02:29:30 AM » |
|
@ msltoe 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 @ 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.
|
|
« Last Edit: January 24, 2016, 02:45:59 AM by mclarekin »
|
Logged
|
|
|
|
M Benesi
|
|
« 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. 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
|
|
« 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
|
|
|
|
|