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 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 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 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?