Indeed, elevation is periodic from -pi to pi. If you want to restrict it to -pi/2 to pi/2, whenever you subtract or sum pi to the elevation you have to subtract or sum pi (it's the same, the period is 2pi) to the azimuth.
Could you try rendering some high power, e.g. z=z^5+c, using both the "corrected elevation", and the cartesian formula z=z*z*z*z*z+c? I'm wondering if they'd look the same.
Actually the azimuth is strictly analogous to Euler's formula, and is automatically periodic as it is formally defined (-pi to pi). The problem is with the elevation, which is where the generalization is involved. I will try z = z^5+c vs. z = z*z*z*z*z+c and see if, with "corrected elevation", they look any different. That is a very good idea.
I find the results of this little experiment a bit suprising. The first thing I did was to compare z^5 + c with z*z*z*z*z + c. If the generalization of Euler's formula to three dimensions is the correct thing to do, the two representations of the 5th power mandelbulb should give the same image. To generate the images I have a power function and a multiply function:
static func Spower(float power, Vector a, Vector b)
; Power function for s = x + iy + jz expressed in spherical coordinates
float r = sqrt(a.m_x^2 + a.m_y^2 + a.m_z^2)+1e-10
float phi = atan2(a.m_x + flip(a.m_y)) ; azimuth
float theta = asin(a.m_z/r)
r = r^power
phi = power*phi
theta = power*theta
b.m_x = r*cos(theta)*cos(phi)
b.m_y = r*cos(theta)*sin(phi)
b.m_z = r*sin(theta)
b.m_w = 0
endfunc
static func SMult(Vector a, Vector b, Vector c)
float ra = sqrt(a.m_x^2 + a.m_y^2 + a.m_z^2)+1e-10
float phia = atan2(a.m_x + flip(a.m_y)) ; azimuth
float thetaa = asin(a.m_z/ra)
float rb = sqrt(b.m_x^2 + b.m_y^2 + b.m_z^2)+1e-10
float phib = atan2(b.m_x + flip(b.m_y)) ; azimuth
float thetab = asin(b.m_z/rb)
float r = ra*rb
float phi = phia + phib
float theta = thetaa + thetab
c.m_x = r*cos(theta)*cos(phi)
c.m_y = r*cos(theta)*sin(phi)
c.m_z = r*sin(theta)
c.m_w = 0
endfunc
To generate z*z*z*z*z + c I used the SMult function to generate z*z*z*z*z and then added c. THE TWO IMAGES ARE VERY DIFFERENT, so I can only conclude that generalizing Euler's formula to three dimensions may not be correct, at least as we have done it. Its possible there is some grevious error in my mult function, but it seems to work correctly in all other applications I have made of it.
The Mandelbulbs (and related other bulbs) as we have implemented them are great fractals, but they may be artifacts of the generalization of the Euler formula to three dimensions. Someone else needs to try this, specifically taking cartesian coordinates to spherical, multiply the r values and add the angles, convert back to cartesian and repeat until z*z*z*z*z is created, and finally add c.