Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => General Discussion => Topic started by: cKleinhuis on April 08, 2012, 06:32:47 PM




Title: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 08, 2012, 06:32:47 PM
hi there,
i am right now for the tvshow preparing a tutorial about what a mandelbulb is, as example i want to develop the mandelbulb formula from standard ultrafractal 5 formula
and i am now ready finished with the formula, but i am unsure if everything is implemented correctly, if somebody could extract slices of various z-values and compare them
to my output ?

i am using triplex definition as defined here
http://www.fractalforums.com/theory/triplex-algebra/

i am just unsure if everything is correct, for example i see large away isles when using exponent 8 and a zslice value of 0.6 but this does not seem to correspond
to standard mandelbulb renderers, or am i just getting it wrong ?

please check!  :police: :alien:
Code:

class Tut_1_4_Standard_Mandelbrot(common.ulb:DivergentFormula) {
;
; Object version of Mandelbrot in Standard.ufm.
; Generic Mandelbrot set.
;
public:
  complex func Init(complex pz)
    fPixelx = real(pz)
    fPixely = imag(pz)
    fPixelz = @zslice

    x=real(@start)
    y=imag(@start)
    z=@start2
    ;just return something
    return @start
  endfunc

  complex func Iterate(complex pz)
  float newreal=       exponentiateWithRealX(x,y,z,real(@p_power))
  float newimag=       exponentiateWithRealY(x,y,z,real(@p_power))
  float newz=       exponentiateWithRealZ(x,y,z,real(@p_power))

    x=newreal+fPixelx
    y=newimag+fPixely
     z=newz+fPixelz
    ; just return something
    return pz;


  endfunc

  bool func IsBailedOut(complex pz)
  ; perform bailout test using our local variables...
return sqrt(x*x+y*y+z*z) > @p_bailout
endfunc

  float func exponentiateWithRealX(float x,float y,float z ,float exponent)
          ; Convert Complex Number z to polar form via:
          float length=sqrt(x*x+y*y+z*z) ; modulus, or simply the length of the number: hello phytagoras!
         if(length==0)
                      length=0.000001
                      endif
                      

          float angle=atan2(x+flip(y)) ; nasty atan2 function that returns the angle of the point from coordinate origin...

          float angle2=asin( z/length)

          ; exponentiate length, just like a normal real number ... when exponentiating it is stretched on x-axis,
          ; in polar coordinates it is stretched along its direction
          float newlength= length^exponent
          ; hence complex multiplication is a rotation, e.g. (0,1i)*(0,1i)=(-1,0) where a 90 degree rotation is performed
          ; we multiply the angle with the exponent ...
          float newangle= angle*exponent
          
          float newangle2= angle2*exponent

          ; now create the complex number from newlength and newangle
          ; using standard sin/cos multiplied by length
          float newreal= (cos(newangle2)*cos(newangle))*newlength
          ;float newimag= sin(newangle)*newlength

          ; create complex number and return, the flip serves as helper to convert the real number to imaginary....
          ; seems to be some compiler problem in uf ... return (newreal,newimag) does an "operator needed" compiler error, dunno why....
          return newreal



  endfunc
  float func exponentiateWithRealY(float x,float y,float z ,float exponent)
          ; Convert Complex Number z to polar form via:
          float length=sqrt(x*x+y*y+z*z) ; modulus, or simply the length of the number: hello phytagoras!
       if(length==0)
                      length=0.000001
                      endif

                         float angle=atan2(x+flip(y)) ; nasty atan2 function that returns the angle of the point from coordinate origin...

              float angle2=asin( z/length)


          ; exponentiate length, just like a normal real number ... when exponentiating it is stretched on x-axis,
          ; in polar coordinates it is stretched along its direction
          float newlength= length^exponent
          ; hence complex multiplication is a rotation, e.g. (0,1i)*(0,1i)=(-1,0) where a 90 degree rotation is performed
          ; we multiply the angle with the exponent ...
          float newangle= angle*exponent
            float newangle2= angle2*exponent

          ; now create the complex number from newlength and newangle
          ; using standard sin/cos multiplied by length
          ;float newreal= cos(newangle)*newlength
          float newimag= (cos(newangle2)*sin(newangle))*newlength

          ; create complex number and return, the flip serves as helper to convert the real number to imaginary....
          ; seems to be some compiler problem in uf ... return (newreal,newimag) does an "operator needed" compiler error, dunno why....
          return newimag

  endfunc

  float func exponentiateWithRealZ(float x,float y,float z ,float exponent)
          ; Convert Complex Number z to polar form via:
          float length=sqrt(x*x+y*y+z*z) ; modulus, or simply the length of the number: hello phytagoras!
      if(length==0)
                      length=0.000001
                      endif

                          float angle=atan2(x+flip(y)) ; nasty atan2 function that returns the angle of the point from coordinate origin...

              float angle2=asin( z/length)


          ; exponentiate length, just like a normal real number ... when exponentiating it is stretched on x-axis,
          ; in polar coordinates it is stretched along its direction
          float newlength= length^exponent
          ; hence complex multiplication is a rotation, e.g. (0,1i)*(0,1i)=(-1,0) where a 90 degree rotation is performed
          ; we multiply the angle with the exponent ...
          ;float newangle= angle*exponent
            float newangle2= angle2*exponent

          ; now create the complex number from newlength and newangle
          ; using standard sin/cos multiplied by length
          ;float newreal= cos(newangle)*newlength
          float newz= sin(newangle2)*newlength

          ; create complex number and return, the flip serves as helper to convert the real number to imaginary....
          ; seems to be some compiler problem in uf ... return (newreal,newimag) does an "operator needed" compiler error, dunno why....
          return newz

  endfunc




private:
  float fPixelx
  float fPixely
  float fPixelz

  float x;
  float y;
  float z;



default:
  title = "Mandelbulb Tut 1_4 - Triplex Exponentiation"
  rating = recommended
  helpfile = "Uf*.chm"
  helptopic = "Html/formulas/standard/mandelbrot.html"
  param start
    caption = "Starting point X/Y"
    default = (0,0)
    hint = "The starting point parameter can be used to distort the Mandelbrot \
            set. Use (0, 0) for the standard Mandelbrot set."
  endparam
  param start2
    caption = "Starting point Z"
    default = 0.0
    hint = "Z-Value Starting Point"
  endparam
 param zslice
    caption = "Z Slice"
    default = 0.0
    hint = "Z-Value Starting Point"
  endparam
  param p_power ; Overrides p_power from Formula
    caption = "Power"
    default = (2.0,0)
    hint = ""
  endparam
  float param p_bailout ; Overrides p_bailout from DivergentFormula
    caption = "Bailout value"
    default = 4.0
    min = 1.0
    exponential = true
    hint = "This parameter defines how soon an orbit bails out while \
            iterating. Larger values give smoother outlines; values around 4 \
            give more interesting shapes around the set. Values less than 4 \
            will distort the fractal."
  endparam
}



Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 08, 2012, 06:34:13 PM
and additionally, how do you deal with length=0 special case ?
as you can see i set length to 0.000001 but i think it would be better to just return 0 ?
but 0^0 = 1 ?


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: DarkBeam on April 08, 2012, 09:03:42 PM
but 0^0 = 1 ?


In maths 0^0 is not determined... In a fractal 0 is almost never 0 so it depends on which value you choose :evil1:


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 08, 2012, 09:28:41 PM
have you checked the formula ?
btw, google says 0^0 = 1
link (https://www.google.de/search?q=0^^0&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:de:official&client=firefox-a#hl=de&client=firefox-a&hs=Rvy&rls=org.mozilla:de%3Aofficial&sclient=psy-ab&q=0^0&oq=0^0&aq=f&aqi=g3g-C1&aql=&gs_l=serp.3..0l3j0i33.1966l1966l0l2191l1l1l0l0l0l0l187l187l0j1l1l0.frgbld.&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=55b95f2eb92cdc6f&biw=1440&bih=716)


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 08, 2012, 09:29:45 PM
the problem is that uf5 breaks down if formula creates a division by zero....


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: asimes on April 08, 2012, 09:30:36 PM
I don't have Ultrafractal, but if it helps pow(0, 0) is 1 for me in Processing.


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: Sockratease on April 08, 2012, 09:56:27 PM
http://betterexplained.com/articles/understanding-exponents-why-does-00-1/

 :nastyteeth:


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 08, 2012, 10:13:30 PM
dudes has anyone tried the formula??????????


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: DarkBeam on April 08, 2012, 10:43:35 PM
but try those calculations

0^t
t^t

Where t is a small value. The result is different ... 0 and 1

Btw... when Makin comes back he will help :)


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 08, 2012, 11:00:18 PM
yea, makin is easter mässig away ... :D
but 0^0=1


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 08, 2012, 11:01:29 PM
or has someone an mandelbulb3d sliced formula that i could use for comparing ???
@darkbeam  :smooth:


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 09, 2012, 03:50:16 AM
i have this slice for triplex z-slice=-0.648993


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 09, 2012, 05:40:41 AM
but isles are valid ;)
i think it should be ok, although it isnt optimised in any ways :(


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: hobold on April 09, 2012, 02:22:30 PM
There is no single consistent definition for 0^0. In my experience, mathematicians just choose 1 or 0 as a result, depending on what's more convenient for a particular line of thought. (I.e. not on a line by line basis. But, say, for the proof of a particular theorem, which would consistently use one of the alternatives.)


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: DarkBeam on April 09, 2012, 06:14:55 PM
hi there,
i am right now for the tvshow preparing a tutorial about what a mandelbulb is, as example i want to develop the mandelbulb formula from standard ultrafractal 5 formula
and i am now ready finished with the formula, but i am unsure if everything is implemented correctly, if somebody could extract slices of various z-values and compare them
to my output ?

i am using triplex definition as defined here
http://www.fractalforums.com/theory/triplex-algebra/

i am just unsure if everything is correct, for example i see large away isles when using exponent 8 and a zslice value of 0.6 but this does not seem to correspond
to standard mandelbulb renderers, or am i just getting it wrong ?

please check!  :police: :alien:

My holy Saint Spaghetti Codes!!! I tried your formula, I must say I would be very curious to see how it's rendered in 3D...
I was able to run it only after creating an ulb. Another complication! ;)
But I can not understand a row of your damnedly complicated code! :-\ :o The "real" formula is far less complicated than that... 5/6 rows of code and no need of all that commentary.  :dink: Please think simpler! Thanks! :dink:


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: DarkBeam on April 09, 2012, 06:16:42 PM
And of course it's completely different from the standard ;D


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: David Makin on April 10, 2012, 04:47:00 AM
"Makin" is back - but a little tired....will check tomorrow evening - oops *this* evening....though after just going for a family wedding in Moray (Scotland) even closer family arrive here from Surrey today at around 4pm......

Of course you could just use the code from my mmf wip formula - in fact I think you could just use the formula as I think it allows cutting planes (though don't rely on that as I'm falling asleep).

http://www.fractalforums.com/mandelbulb-implementation/update-to-the-mmf-wip-formula-for-ultra-fractal/



Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 10, 2012, 09:45:16 AM
the reason for this tutorial is to develop the mandelbulb formula from scratch, any hints
on compacting the code are welcome, but it shall serve as :
*how-to write formulas for ultrafractal,
*what is polar exponentiation
*what is spherical exponentiation
*and it shall be developed from scratch from the standard mandelbrot formula
* should serve as well as general introduction into fractal stuff and what we do here on the forums
* invite people to experiment with the formula editors
* general fractal math tutorial

it will be georgeous, and is planned as one of the first tvshow entries, it will consist of nearly 10 parts, and i talk something, and then switching to the ultrafractal screen... stay tuned...

any hints and comments are welcome,as well as hinting me where to make changes for the cosine/sine mandelbulb variant ... :)


and in fact, i still have a question:

WHY IS THE ANGLE CALCULATION FOR THE SECOND ANGLE NOT USING ATAN2 FUNCTION ? !?
in my eyes it would be much simpler to adopt the atan2 function to just use another pair of coordinates, but why the heck it is calculated by "asin(z/r)" ?!?!?!


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: DarkBeam on April 10, 2012, 11:40:57 AM
WHY IS THE ANGLE CALCULATION FOR THE SECOND ANGLE NOT USING ATAN2 FUNCTION ? !?
in my eyes it would be much simpler to adopt the atan2 function to just use another pair of coordinates, but why the heck it is calculated by "asin(z/r)" ?!?!?!


You can convert asin() to atan2(); I did that in my implementation, as arcsin() simply does not exist in f.p. assembly! :dink:

See General formula help. :nerd:

arcsin(z/r) = atan2(z, hypot(x,y))  :D

hypot(x,y) = sqrt(x*x + y*y)

asin(z/r) = azimuth angle


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: DarkBeam on April 10, 2012, 11:47:36 AM
btw Mandelbulb3d has a 2d mode, that you can explore using the rotation buttons, spin it all around! :crazyeyes:


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: David Makin on April 11, 2012, 09:48:32 PM

WHY IS THE ANGLE CALCULATION FOR THE SECOND ANGLE NOT USING ATAN2 FUNCTION ? !?
in my eyes it would be much simpler to adopt the atan2 function to just use another pair of coordinates, but why the heck it is calculated by "asin(z/r)" ?!?!?!


Because you need r anyway (usually) and asin (on fpu) is considerably faster than atan2 ;)

Sorry still haven't had time to check the code - things are still hectic here as although I'm back home from Scotland my brother and family are here at the moment (Steve, Christine, Max, Zoe, Yasmine and George) plus I'm trying to process all the pics I took while in Scotland among other things....


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 11, 2012, 10:25:54 PM
@darkbeam, me: "ah, great that makes sense thank you for clarification ... although i cant explain it with my own words yet i am happy", right the mandelbulb3d has a 2d mode, but i never understood how to correctly use it, and what 3d picture results from it ;) but just because i didnt spent too much time to find it out ...
but i will do it in ultrafractal, because i want to just show properties of fractal formulas in general, and ultrafractal in special... and at the end we will shortly watch mandelbulb3d and mandelbulber do their beautiful work ...

@dave take your time, i am interested what you say about how correct it is, in general but your uf5 expertise is also wanted,
 e.g. returning z value only in the iteration loop could lead to not so nice coloring problems,  or how to make "power" variable defined in base class a float, or at least hide it from display 


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 11, 2012, 10:30:55 PM
My holy Saint Spaghetti Codes!!! I tried your formula, I must say I would be very curious to see how it's rendered in 3D...
I was able to run it only after creating an ulb. Another complication! ;)
But I can not understand a row of your damnedly complicated code! :-\ :o The "real" formula is far less complicated than that... 5/6 rows of code and no need of all that commentary.  :dink: Please think simpler! Thanks! :dink:

lol, are you real ?
it shall serve as a tutorial, and every line that stands there has to fulfil a certain purpose or has to get lost ... :D ....
and i used some nasty copy&paste code, that will be discussed in the tutorial as well, and that it is clearly not a speed
optimized code is known to me as well ( nasty function calls ) but this structure allows easy understanding for not so
fractal-assembler-affine people ...

problem is that many many parts of the code just deal with some shortcomings that ultrafractal parser has ... e.g. i dont know how to create a complex number on the fly i needed some time to find out that x+flip(y) has to be used to make a complex number out of x/y

and some parts are declaring and using local variables for storing the iteration inbetween results hence uf5 just deals with complex numbers in the iter loop, and i wanted to store all parts of the number, and not only the z ... just to make things even clearer what is happening ...

and for sure i am going to switch start values at the start of the tutorial to show how to create julia sets :D :D :D :D


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: David Makin on April 12, 2012, 11:26:29 PM
or how to make "power" variable defined in base class a float, or at least hide it from display  

In the derived class have a parameter of the same name and type as the one in the parent class but with "visible=false".


Title: Re: can someone confirm correctness of uf5 mandelbulb formula?
Post by: cKleinhuis on April 13, 2012, 12:57:41 PM
ah, thanks, what about casting/creating complex numbers on the fly ?
i would like to return it this way:
return (real,imag)
i am working on the steps of the formula, commenting every line, and parameter :D
will let you review it ....