Logo by Fiery - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Visit us on facebook
 
*
Welcome, Guest. Please login or register. January 10, 2026, 09:20:33 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Elevation correction  (Read 2672 times)
0 Members and 1 Guest are viewing this topic.
fractalrebel
Fractal Lover
**
Posts: 211



WWW
« on: December 08, 2009, 12:18:26 AM »

In the standard Mandelbulb formula the iterated z value is determined primarily by the elevation, which comes from

phi = asin(z/r)

where -pi/2 <= phi <= pi/2
which is the range for the elevation

and z = r*sin(phi)

When phi is multiplied by the Mandelbrot power it will often fall outside this range. The value of phi can be corrected to always be in the correct range by the operation phi = asin(sin(phi)).

This correction has a substantial effect on the appearance of the image. Here are examples for the 2nd power Juliabulb (Julia seed = -0.75 + i*0.25), first without the correction, and second, with the correction.


* Juliabulb_standard.jpg (114.46 KB, 900x720 - viewed 320 times.)

* Juliabulb_elevation_correction.jpg (157.64 KB, 900x720 - viewed 332 times.)
Logged

fractalrebel
Fractal Lover
**
Posts: 211



WWW
« Reply #1 on: December 08, 2009, 12:20:26 AM »

Here are two examples for a 5th power mandelbulb. The differences are smaller, but still significant.


* FifthPowerMandelbulb_standard.jpg (147.11 KB, 720x900 - viewed 331 times.)

* FifthPowerMandelbulb_elevation_correction.jpg (139.79 KB, 720x900 - viewed 328 times.)
Logged

David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #2 on: December 08, 2009, 01:14:42 AM »

Hi Ron, isn't there a better fix than having to use extra trig ?
Also I take it that in both cases the second of the two images is the corrected one - in that case I much prefer the uncorrected version smiley
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
Paolo Bonzini
Guest
« Reply #3 on: December 08, 2009, 01:48:38 AM »

When phi is multiplied by the Mandelbrot power it will often fall outside this range. The value of phi can be corrected to always be in the correct range by the operation phi = asin(sin(phi)).

Applying the correction is wrong, as it will flip the sign of the x and y coordinates.  The equivalent of spherical coordinates (rho,theta,phi) with phi out of range is (rho,theta+pi,phi+pi).  The "theta+pi" changes the sign of x and y once more.  You can try visualizing on a sphere, for example (1,pi/2,3pi/4) and (1,-pi/2,-pi/4).  The 3pi/4 version basically goes around the pole and ends up on the other side of the sphere (same as going from South Africa to New Zealand).
Logged
fractalrebel
Fractal Lover
**
Posts: 211



WWW
« Reply #4 on: December 08, 2009, 02:13:58 AM »

When phi is multiplied by the Mandelbrot power it will often fall outside this range. The value of phi can be corrected to always be in the correct range by the operation phi = asin(sin(phi)).

Applying the correction is wrong, as it will flip the sign of the x and y coordinates.  The equivalent of spherical coordinates (rho,theta,phi) with phi out of range is (rho,theta+pi,phi+pi).  The "theta+pi" changes the sign of x and y once more.  You can try visualizing on a sphere, for example (1,pi/2,3pi/4) and (1,-pi/2,-pi/4).  The 3pi/4 version basically goes around the pole and ends up on the other side of the sphere (same as going from South Africa to New Zealand).

phi + pi will definitely put phi out of range. The range for phi is -pi/2 to pi/2.
Logged

Paolo Bonzini
Guest
« Reply #5 on: December 08, 2009, 02:24:01 AM »

phi + pi will definitely put phi out of range. The range for phi is -pi/2 to pi/2.
Summing pi or subtracting pi is the same, since all trig functions are periodic.  The important point is that these aren't abstract operation on angles, they are operations on points of a sphere and "correcting" phi as asin(sin(phi)) will make you "jump" to the other side of the sphere.
Logged
fractalrebel
Fractal Lover
**
Posts: 211



WWW
« Reply #6 on: December 08, 2009, 06:49:12 PM »

Please notice that the range -pi/2 to pi/2 for the elevation is not periodic, unlike the range for the azimuth. Also, we are not dealing with simple spherical coordinates, but rather a generalization of Euler's formula to three dimensions.
Logged

Paolo Bonzini
Guest
« Reply #7 on: December 08, 2009, 07:51:03 PM »

Please notice that the range -pi/2 to pi/2 for the elevation is not periodic
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.  Doing asin(sin(phi) blindly changes the sign of x and y.

Also, we are not dealing with simple spherical coordinates, but rather a generalization of Euler's formula to three dimensions.
True, and it matters a lot (for example) when doing computation on the cartesian form.  In that case you're forcing the elevation from -pi/2 to pi/2 because you treat this generalization as spherical coordinates.  And, it changes the results so that they differ from the trig formula.

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.
Logged
fractalrebel
Fractal Lover
**
Posts: 211



WWW
« Reply #8 on: December 08, 2009, 09:26:14 PM »

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.
Logged

fractalrebel
Fractal Lover
**
Posts: 211



WWW
« Reply #9 on: December 08, 2009, 10:36:08 PM »

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.



Logged

David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #10 on: December 08, 2009, 10:58:32 PM »

Hi, actually Paul (bugman) showed a while ago that the multiply and power functions do not match up and we've just been discussing that in the triplex algebra thread - that's one reason I was surprised when Jos Leys' method for the derivative worked for getting the distance estimate.
Basically multiply for the triplex is commutative but not associative.
« Last Edit: December 08, 2009, 11:02:59 PM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
JosLeys
Strange Attractor
***
Posts: 258


WWW
« Reply #11 on: December 08, 2009, 11:52:04 PM »

I think I know the reason why the images are different.

(See Ron's code)
Suppose the point in question has theta=60°.

Let's do consecutive multiplication first for z*z*z. After the first pass theta becomes 120°.So c.m.z becomes r.sin(120°)
Second pass : thetaa will give 60°, not 120°, while thetab is 60°, so theta is again 120°..

Now the power function: theta becomes 3*60=180°

It's the 'truncation' of the sine function that makes the difference..

Logged
Paolo Bonzini
Guest
« Reply #12 on: December 09, 2009, 01:28:51 AM »

Yes, we've seen it in the triplex algebra thread.  I'm thinking now that the commutative multiplication of spherical numbers is a red herring and doesn't really make much sense, and I'm writing down better what I scribbled in the "REAL math behind the Mandelbulb" post.  Stay tuned.
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.402 seconds with 25 queries. (Pretty URLs adds 0.013s, 2q)