Mandelbulb: 3D Mandelbrot Fractal

Mandelbulb

double pi=3.14159265;
double r    = sqrt(x*x + y*y + z*z );
double yang = atan2(sqrt(x*x + y*y) , z  )  ;
double zang = atan2(y , x);
newx = (r*r) * sin( yang*2 + 0.5*pi ) * cos(zang*2 +pi);
newy = (r*r) * sin( yang*2 + 0.5*pi ) * sin(zang*2 +pi);
newz = (r*r) * cos( yang*2 + 0.5*pi );