Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => The 3D Mandelbulb => Topic started by: Aexion on August 06, 2014, 12:43:11 PM




Title: MandelDonuts
Post by: Aexion on August 06, 2014, 12:43:11 PM
Hello,

Lately I have been trying to make a toroidal Mandelbulb. Since the mandelbulb uses spherical coordinates, I wondered if one could create a torus based version.
After trying with the Toroidal coordinate system with no luck, I moved on a simple parametric curve that gives me very interesting results.
My idea was to calculate the mandelbulb angles and distances over a circular path, that turns it into a torus.
The resulting fractals are made of a combination of donuts and bridges.
By calculating the mandelbulb in this way, also opens other possibilities, since you can use other parametric curves.
I tried and spiral and also got very interesting results.
These functions are quite simple and just returns true or false if you're in the fractal or not.


MandelTorus1

(http://www.rfractals.net/share/MandelTorus1.png)
Code:
bool MandelTorus1(double x, double y, double z,int iter){
const float cx=x;
const float cy=y;
const float cz=z;
const int power1=9; //Longitude power
const int power2=9; //Latitude power
const double tdist=1.5;//radius of the parametric circle.  Make it 0 if you want a dual power mandelbulb
unsigned char Counter=0;
float rh =x*x+z*z;
do{
rh=sqrt(rh);
const double phi=atan2(z,x);
const double phipow=phi*power1;
const double theta=atan2((double)rh,(double)y);
const double thetapow=theta*power2;
const double px=x-cos(phi)*tdist;
const double pz=z-sin(phi)*tdist;
const double rhrad=sqrt(px*px+pz*pz+y*y);
const double rh1=pow(rhrad,power2);
const double rh2=pow(rhrad,power1);
const float sintheta=sin(thetapow)*rh2;
x = sintheta * cos(phipow)+cx;
z = sintheta * sin(phipow)+cz;
y = cos(thetapow)*rh1+cy;
rh =x*x+z*z;
if (rh+y*y>16) break;//bailout
Counter++;
}while(Counter<iter);

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

MandelTorus2

(http://www.rfractals.net/share/MandelTorus2.png)(http://www.rfractals.net/share/MandelTorus2Zoom.png)
Code:
bool MandelTorus2(double x, double y, double z,int iter){
const float cx=x;
const float cy=y;
const float cz=z;

const int power1=9; //Longitude power
const int power2=9; //Latitude power
const double tdist=1.5;
unsigned char Counter=0;
float rh =x*x+z*z;
do{
rh=sqrt(rh);
const double phi=atan2(z,x);
const double phipow=phi*power1;
const double theta=atan2((double)rh,(double)y);
const double px=x-cos(phi)*tdist;
const double pz=z-sin(phi)*tdist;
const double rhrad=sqrt(px*px+pz*pz+y*y);
const double tangle=atan2(sqrt(px*px+pz*pz),(double)y)*power2;
const double rh1=pow(rhrad,power2);
const double rh2=pow(rhrad,power1);
const float sintheta=(1.5+cos(tangle))*rh2;
x = sintheta * cos(phipow)+cx;
z = sintheta * sin(phipow)+cz;
y = sin(tangle)*rh1+cy;
rh =x*x+z*z;
if (rh+y*y>16) break;
Counter++;
}while(Counter<iter);

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

There are many variations to test, such as spirals, elliptic curves, and knots. Also, you can add a waving Y axis component to the circle, that will turn the torus into some sort of flower and creates a mandelflower set.  

Hope that you like it. If anyone can calculate the DE for these fractals, I will be very good.

Thanks!

ps. I have many other fractals to show in store, such as the Spherical Harmonics fractals, but lately have been busy working with Aural  (http://www.auralfractals.net/) and has little time left to explore.
pps. Is there a section for indexing all 3D fractals? Say something like an image, the formula and a comment. I say that because this would prevent us to reinventing the wheel (something that happened to me sometime ago) and helps to the fractal programmers to code them!. :)
ppps. Where I the forum I can announce my fractal music generator?  ;D



Title: Re: MandelDonuts
Post by: Roquen on August 06, 2014, 09:57:06 PM
Nice.  Spherical Harmonics seems like an interesting idea.


Title: Re: MandelDonuts
Post by: Aexion on August 07, 2014, 01:40:11 AM
Nice.  Spherical Harmonics seems like an interesting idea.
Indeed, they can produce very interesting fractals:  ;D
(http://www.rfractals.net/share/SphericalHarmonic1.jpg)(http://www.rfractals.net/share/SphericalHarmonic2.jpg)
(http://www.rfractals.net/share/SphericalHarmonic3.jpg)(http://www.rfractals.net/share/SphericalHarmonic4.jpg)


Title: Re: MandelDonuts
Post by: _revers_ on August 07, 2014, 09:20:55 AM
QL :) I thing MandelTorus2 looks better than Mandelbulb.


Title: Re: MandelDonuts
Post by: cKleinhuis on August 07, 2014, 09:27:14 AM
cool way to hybridise even more ;) havent looked fully into how you do it, because it is hidden in the complete formula,
you apply the torus transform in every iteration rather than as pre-transform ?


Title: Re: MandelDonuts
Post by: Roquen on August 07, 2014, 10:51:18 AM
Just in case you haven't seen these:
http://www.ppsloan.org/publications/StupidSH36.pdf
http://jcgt.org/published/0002/02/06/
http://www.filmicworlds.com/2014/07/02/simple-and-fast-spherical-harmonic-rotation/


Title: Re: MandelDonuts
Post by: Aexion on August 07, 2014, 01:45:17 PM
cool way to hybridise even more ;) havent looked fully into how you do it, because it is hidden in the complete formula,
you apply the torus transform in every iteration rather than as pre-transform ?
For the first formula, it just a circle.
I just use an angle from the Mandelbulb to calculate point in a circle, then the mandelbulb radius is calculated by subtracting that point from the actual iteration formula. Is a very simple approach.

The second formula is actually an attempt to use the torus equation, but it also uses the circle procedure.


Title: Re: MandelDonuts
Post by: Aexion on August 07, 2014, 05:02:12 PM
Here is a simple way to distort the Mandelbulb into the Spherical Harmonics functions. Its the same as in the MandelTorus1 function,
but instead using just a parametric circle, the point comes from the harmonic's parametric surface.
Any change in the powers of the mandelbulb or the spherical harmonic coefficients will make interesting shapes (they are good for making orange juice too.. :) )
I didn't have tested the SuperFormula, but I suspect that they will work in the same way..
For the information of the Spherical Harmonics, Paul Bourke has a very good webpage about them, here is the link: http://paulbourke.net/geometry/sphericalh/ (http://paulbourke.net/geometry/sphericalh/)
(BTW, Thanks for the links, I will check them!)

(http://www.rfractals.net/share/HarmonicBulb1.png)(http://www.rfractals.net/share/HarmonicBulb2.png)

Code:
bool HarmonicBulb(double x, double y, double z,int iter){
const double m[8]={2,4,2,4,2,4,2,4}; // Spherical Harmonics coefficients.. Any integer makes something interesting (or not!)
const float cx=x;
const float cy=y;
const float cz=z;

float rh =x*x+z*z;
const int power1=13;//Longitude
const int power2=13;//Latitude.. Try 5 for the second example

double r;
unsigned int Counter=0;
do{
rh=sqrt(rh);
const double phi=atan2(z,x);
const double phipow=phi*power1;
const double theta=atan2((double)rh,(double)y);
const double thetapow=theta*power2;
r=pow(sin(m[0]*phi),m[1]);
r += pow(cos(m[2]*phi),m[3]);
r += pow(sin(m[4]*theta),m[5]);
r += pow(cos(m[6]*theta),m[7]);
const double hsintheta=sin(theta)*r;
const double px=x-hsintheta*cos(phi);
const double pz=z-hsintheta*sin(phi);
const double py=y-cos(theta)*r;
const double rhrad=sqrt(px*px+pz*pz+py*py);
const double rh1=pow(rhrad,power2);
const double rh2=pow(rhrad,power1);
const float sintheta=sin(thetapow)*rh2;
x = sintheta * cos(phipow)+cx;
z = sintheta * sin(phipow)+cz;
y = cos(thetapow)*rh1+cy;
rh =x*x+z*z;
if (rh+y*y>16) break;
Counter++;
}while(Counter<iter);

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





Title: Re: MandelDonuts
Post by: mclarekin on August 08, 2014, 06:45:01 AM
@ Aexion. Thanks for sharing, they look great. The infinite possibilities have just got more infinite ;D


Title: Re: MandelDonuts
Post by: DarkBeam on February 14, 2015, 04:54:14 PM
GENIUS! :D


Title: Re: MandelDonuts
Post by: LMarkoya on February 14, 2015, 05:17:05 PM
Are you actually doing those in Incendia??????


Title: Re: MandelDonuts
Post by: DarkBeam on February 14, 2015, 11:45:15 PM
I remember he uses a kind of voxelstack export and renders with Incendia without using distance estimation :) the hard way :D


Title: Re: MandelDonuts
Post by: cKleinhuis on February 14, 2015, 11:49:07 PM
naah, far to smooth for a voxelstack export ;) i think a plain raymarche does the job here ;)

beside of that, it reminds me of the pre-transforms in ultrafractal, wouldnt it be nice to have a space warp pre transform step built in into the current renderers? i talk about mandelbulber ;) will post it right away there ;)


Title: Re: MandelDonuts
Post by: DarkBeam on February 14, 2015, 11:53:20 PM
Uh, there is a ton of them I made but don't press the poor Buddhi! :D


Title: Re: MandelDonuts
Post by: cKleinhuis on February 15, 2015, 12:06:41 AM
sure, since it is an open source project anyone can do it ;)

so, i am certainly not able to do it right now, but a generalised approach for mandelbulber, and a description of our 2 different approaches

- me: just one transform before iterating
- you: a transfom at each iteration?

is nice to have included them in the general workflow of mandelbulber .... since it is the only one under construction right now ;)


Title: Re: MandelDonuts
Post by: DarkBeam on February 15, 2015, 08:33:06 AM
sure, since it is an open source project anyone can do it ;)

so, i am certainly not able to do it right now, but a generalised approach for mandelbulber, and a description of our 2 different approaches

- me: just one transform before iterating
- you: a transfom at each iteration?

is nice to have included them in the general workflow of mandelbulber .... since it is the only one under construction right now ;)

Well the ideal thing would be to leave the user decide when to iterate them or not.
Some pretransforms look more cool iterated really. :)


Title: Re: MandelDonuts
Post by: DarkBeam on February 15, 2015, 07:01:01 PM
This project is similar to the older BradC topic: http://www.fractalforums.com/theory/toroidal-coordinates/msg9428/

That I almost forgot, by the way Aexion surely didn't see the old one :)

Also the msltoe variant looks promising ^-^