New formula - fixing the whipped cream quaternion issue.....

  • 21 Replies
  • 626 Views

0 Members and 1 Guest are viewing this topic.

Offline FractalDave

  • *
  • Uploader
  • *
  • Posts: 171
    • Makin Magic Fractals
« on: October 01, 2018, 03:45:06 AM »
Hi all,
A power 5 quaternion (restricted to 3D) but with an initial manipulation of i/j such that the magnitude isn't affected - 10 points for anyone who can guess what I've done.
I'm very pleased with the results, even for the power 2 version - the technique can also work on a*b as well as a^p
Will give y'all till I get on here tomorrow during daylight hours to reply with the secret.....
bye
Dave
The meaning and purpose of life is to give life purpose and meaning.

Offline Sabine62

  • *
  • Fractal Frankfurter
  • *
  • Posts: 572
  • It's just a jump to the left...
    • sabine62.deviantart.com
« Reply #1 on: October 01, 2018, 10:22:53 AM »
Can't take a shot as have no clue about maths :D but Wow!  :thumbs: :thumbs: :thumbs: Always thought of quaternions as a bit dull, due to the lack of detail, until now...
Looking forward to more about this.
To thine own self be true

Offline FractalDave

  • *
  • Uploader
  • *
  • Posts: 171
    • Makin Magic Fractals
« Reply #2 on: October 01, 2018, 12:16:45 PM »
First a little background - this formula came about after I was rethinking an idea I discussed on the old fractalforums site i.e. that the i/j or y/z, i.e. the first and second imaginary axes in 3D, should have distributed bulbs around the centre (the r or x axis) as do the normal complex fractal for z^4+c (3 bulbs) or even better z^5+c (4 bulbs). I'd tried various versions of this before without success with respect to creating a "better" Mandelbulb but always failed.
However yesterday it struck me that if the i/j (or y/z) of the 3D was subjected to the rotation involved but not the scaling and then a subsequent full dimensional formula applied (such as 3D restricted quaternion) hopefully the result would be as required as my previous efforts mainly failed due to issues of relative magnitudes.
So here's the iterative formula as it currently stands as an Ultra Fractal func straight from my working updates version of MMFWip3D, I've also realised (whilst writing this) that it would be more flexible if the quaternionic part was also split between magnitude power and angle scaling since that would probably produce even more nice bulbs ;)
For those not familiar with UF notation |x+iy| returns x^2+y^2 i.e. the magnitude squared and not the actual magnitude, cabs(x+iy) returns the magnitude directly. Also for anyone not familiar, yes those are some assignments in brackets - coding this way, although harder for us to read, gives the compiler more options.

Code: [Select]
  func test3D7(complex &z,complex &w)
    float m = |z|+sqr(real(w))
    if m>0
      float s = cabs(w=imag(z)+flip(real(w)))
      if s>0
        float r = real(z)
        w = w^@bulba*s^(@bulbm-@bulba)
        if @bulbm!=1
          m = |r+flip(s=s^@bulbm)|
        endif
        if @bulbq==2
          z = sqr(r) - |w| + flip(2.0*r*real(w))
          w = 2.0*r*imag(w)
        else
          r = @bulbq*acos(r/(m=sqrt(m)))
          w = m^@bulbq*sin(r)*w/s
          z = m^@bulbq*cos(r)+flip(real(w))
          w = imag(w)
        endif
      else
        z = real(z)^@bulbq
      endif
    endif
  endfunc

@bulba, @bulbm and @bulbq are user parameters (all float) - "a" gives the angle scaling for i/j, "m" gives the magnitude power for i/j and bulbq gives the quaternionic power.

The original post in this thread has a render using 5 for the angle scaling, 1 for the magnitude power and 5 for the quat power.
The image attached to this post uses 8, 1, 8 and produces results incredibly similar to the original White/Nylander degree 8 - however note:

1. No asymptotic "stars"
and
2. (I think) No "whipped cream", even the stretched parts clearly have fractal detail.

Please feel free to add to your own software as you like - though a credit would be much appreciated - ideally with links to:

http://www.fractalgallery.co.uk/
and
https://www.facebook.com/david.makin.7

Thanks for reading and enjoy !!

Offline lycium

  • *
  • Fractal Friend
  • **
  • Posts: 19
« Reply #3 on: October 01, 2018, 02:46:58 PM »
Looks interesting :) Would be nice to have an analytic distance estimate for it.

I'm not familiar with UF language, and haven't seen anything like a return statement in there... what does this function return? Does it modify the x and w vectors? They are also 2D complex values and not 3D, no? With some clearer "recipe" I would be happy to give it a quick try.

Offline Sabine62

  • *
  • Fractal Frankfurter
  • *
  • Posts: 572
  • It's just a jump to the left...
    • sabine62.deviantart.com
« Reply #4 on: October 01, 2018, 04:17:46 PM »
David, as I am a mere mortal ,though I really try to understand what is happening in this piece of code as for now I cannot make head or tales on how you use the 2D vectors (?) z and w? Should say that I have no idea about UF code...

As I understand you pluck apart the y- and z-parts of the 34D vector in order to be able to include (for rotation) or exclude (for scale)  and then later reunite them with the real axis.
Somehow I get the idea that in your code you use the z as (real)x- and (imaginary)y-axes and the w as (imaginary)z- and w-axis?, but I am pretty sure I get this wrong? Because I find you also use the w.y.

For Fragmentarium (which is not very forgiving (to me, at least ;) )) I need to use a syntax like p.xyzw ultimately, and as of now I get errors of overloaded functions when trying to use a float as power to a vec2 and such.
f.i. w = pow(w,bulba)*pow(s,(bulbm-bulba)); which is your w = w^@bulba*s^(@bulbm-@bulba)

A true sign that I get things wrong... Would you care to elaborate?
And also any idea for the DE would be great, indeed :)

« Last Edit: October 01, 2018, 04:44:40 PM by Sabine62 »

Offline FractalDave

  • *
  • Uploader
  • *
  • Posts: 171
    • Makin Magic Fractals
« Reply #5 on: October 01, 2018, 06:02:48 PM »
More explanation of the code:

First of all a "func" is your own definition of a function call so this one is called by the main code as test3D7(a,b) where a and b are any complex variables though for this particular instance on entry the imaginary part of b is always zero.
The ampersands (&) in the function definition of entry value means that the complex a,b are passed by reference i.e. so within the func "z" actually refers directly to the passed variable "a" and  w to b rather than a,b being copied into separate variables z,w - obviously pass by reference is faster and no return values are required at the end of the func.
Quaternions can be treated as a real plus a 3D vector i.e. (a,b,c,d) can be treated as (s,V) where s is just a real and V is the 3D vector made up of (b,c,d). Also for the purposes of this case it's generally OK to treat a 3D system as a restricted quaternion where the vector is just a 2D one, or indeed simply treated as a complex number i.e. (a,b,c) treated as (s,V) where V is made-up of (b,c). In addition in both cases the magnitude of V can be treated as the imaginary part of a complex number (s,m) where m is the vector's magnitude.
The code first gets the square of the full 3D magnitude - avoiding the unnecessary square root calculation at this point.
Then we only need to do further processing on non-zero values.
On the line declaring s there is also a re-assignment of w so that it contains the full complex vector made up of the imaginary part of z as the real part and what was the real part of w as the imaginary and s is assigned the magnitude of this (I've since realised that I should again be just calculating the square here and put the root calculation after the if test…)
if s is non-zero then we need to process the vector and first the real part of z is copied into r which I've now realised isn't strictly necessary at this point ;)
Now we raise w to the power required by the angle scaling parameter and multiply by the magnitude to the power of the difference between the magnitude power parameter and the angle scaling parameter resulting in a new value for w such that the angle is scaled by bulba but the magnitude is raised to power bulbm. Normally bulbm should be 1 so that the magnitude of the vector is unchanged but the angle has been scaled as required.
If the value of bulbm is not 1 then we have to recalculate both m (the full 3D magnitude squared) and s (the magnitude of the 2d vector w), here for the new s raising a float to a power will be faster than using |w| whenever the power parameter is actually an integer (smart Frederik compiling).
In the next section the quaternionic calculations are done, for the power 2 version simply giving (x,y,z)^2 as (x^2-y^2-z^2, 2xy, 2xz) and for other powers using the classic angle scale and magnitude power method but obviously for quaternions this time.
Before the endfunc of course the first two parts are back in z and the third in the real part of w with the imaginary part of w being zero.
If the vector was zero then obviously we simply raise the real part to the power.

NB. edited to correct "bulbp" to "bulbm" and to mention that on exit of the func the imaginary part of w is zero....
« Last Edit: October 01, 2018, 08:48:10 PM by FractalDave »

Offline Sabine62

  • *
  • Fractal Frankfurter
  • *
  • Posts: 572
  • It's just a jump to the left...
    • sabine62.deviantart.com
« Reply #6 on: October 01, 2018, 06:41:23 PM »
I will print out your explanations and hang them above my bed and promise to stare at them whenever I dare to  ;)

Now seriously: Looks a bit intimidating to me at first glance, but will have a thorough look at it holding it against your code.
Thank you very much, David, I really appreciate this! :thumbs: :thumbs: :thumbs:

Offline FractalDave

  • *
  • Uploader
  • *
  • Posts: 171
    • Makin Magic Fractals
« Reply #7 on: October 01, 2018, 08:40:59 PM »
With respect to distance estimation Buddhi's method works fine but an analytic method should be possible I think, I'm still investigating the possibilities with respect to this style of formula e.g. what if other types of "usual" 3D methods are used instead of quaternions and can something similar be done for full 4D ?
Also I haven't even started investigating the Julias yet !!

Offline FractalDave

  • *
  • Uploader
  • *
  • Posts: 171
    • Makin Magic Fractals
« Reply #8 on: October 01, 2018, 08:58:03 PM »
pow(w,bulba)*pow(s,(bulbm-bulba))

looks correct - bulbm and bulba should be floats, w should be complex and s float.
So if the pow function only takes (complex,complex) or (float,float) then you may need to copy floats into temporary complex variables:

e.g. (pseudo-code) add

complex t = bulba

and use pow(w,t) instead of pow(w,bulba)

though ideally just using pow(w,(complex)bulba) should work ;)

Unfortunately I'm not familiar with the usual Vec2 format, I just know complex used as complex or as two floats by accessing the real and imaginary individually ;) Maybe you can do this by accessing the individual parts of a Vec2 e.g. pow(w,(vec2)(bulba,0))

Offline claude

  • *
  • 3e
  • *****
  • Posts: 1063
    • mathr.co.uk
« Reply #9 on: October 01, 2018, 09:51:59 PM »
GLSL has no notion of complex numbers. Fragmentarium comes with a Complex.frag to use vec2 as complex numbers, vec4 as dual complex numbers for automatic differentiation, and double versions too.

Offline gerrit

  • *
  • 3f
  • ******
  • Posts: 1632
« Reply #10 on: October 02, 2018, 04:02:54 AM »
For those not familiar with UF notation |x+iy| returns x^2+y^2 i.e. the magnitude squared and not the actual magnitude, cabs(x+iy) returns the magnitude directly. Also for anyone not familiar, yes those are some assignments in brackets - coding this way, although harder for us to read, gives the compiler more options.
Do you actually make these 3D images in UF? If so, could you share code on how to do that?

Offline FractalDave

  • *
  • Uploader
  • *
  • Posts: 171
    • Makin Magic Fractals
« Reply #11 on: October 02, 2018, 09:41:07 AM »
Do you actually make these 3D images in UF? If so, could you share code on how to do that?

UFM zipped:
http://www.fractalgallery.co.uk/MMFwip3D.zip

Info:
http://www.fractalforums.com/amazing-box-amazing-surf-and-variations/tglad's-mandelbox-and-using-the-delta-de-methods-for-rifs/15/
http://www.fractalforums.com/ultrafractal/help-with-mmfwip3d/
http://www.fractalforums.com/theory/summary-of-3d-mandelbrot-set-formulas/

It's worth checking that first thread from the start I think ;)

Also for a slightly different take on 3D+ in UF check out Ron Barnett's reb.ufm:3D raytrace
Also note that my mmf4.ucl (from the UF formula database) has the colouring to go with my Wip3D formula and there's a similar one for Ron's 3D in reb.ucl - Ron's formulas are in the public UF formula database.
I've just noticed that there may now be more 3D ray-casting/tracing formulas by other authors in the database too.
« Last Edit: October 02, 2018, 10:11:51 AM by FractalDave »

Offline gerrit

  • *
  • 3f
  • ******
  • Posts: 1632
« Reply #12 on: October 02, 2018, 06:57:10 PM »
Wow, that's some code. Thanks a lot!

Offline Sabine62

  • *
  • Fractal Frankfurter
  • *
  • Posts: 572
  • It's just a jump to the left...
    • sabine62.deviantart.com
« Reply #13 on: October 02, 2018, 08:01:31 PM »
Thanks, David, for all for the extra input.

Like claude pointed out, a problem of this code for me - among others :embarrass: - that glsl/opengl cannot do complex. We have (thank you claude for providing them and also for reminding me of them! :) ) complex number functions but still complex numbers have to be represented as vectors (though as I understand can be treated like complex numbers), hence my attempt to use two 2D vectors for your complex variables z and w and for the overloaded power function I had just taken the axes apart like
w=pow(w,bulba)*pow(s,(bulbm-bulba)) <---->  w.x = pow(w.x,bulba)*pow(s,(bulbm-bulba));
                                            w.y = pow(w.y,bulba)*pow(s,(bulbm-bulba));
which in the end hopefully would have turned out to do the same...
But the complex power function should be able to tackle the whole vec2 in one go, and even correctly... So probably won't need to resort to the 'pseudo-code' ;)

I'm enjoying this immensely :yes:


PS: Still have to continue reading and processing  ;) your elaborate explanations, hopefully will have more time later tonight or tomorrow evening.
PS2: In Fragmentarium we have an experimental "creamy" QuaternionMandelbrot4D.frag which uses this DE:
     return  0.5 * r * log(r) / length(dp);
where r is the lengths of the vec4 and dp a product of a lot of swizzled and twiddles which make my eyes water
Have attached the .frag for anyone who is interested.

Offline FractalDave

  • *
  • Uploader
  • *
  • Posts: 171
    • Makin Magic Fractals
« Reply #14 on: October 03, 2018, 04:17:20 AM »
I've decided to name fractals of this type "rotabulbs": in this example Mandy there is an initial rotation by scaling the angle of y,z around the x axis by 12 and then raising (x,y,z) to power 12 in the quaternionic way for 3D i.e. with the 4th dimension unchanged at zero.


clip
"Whipped Cream" on steroids

Started by FractalDave on Fractal Mathematics And New Theories

2 Replies
156 Views
Last post November 12, 2018, 11:42:05 PM
by FractalDave
xx
Ice Cream Sandwich

Started by quaz0r on Fractal Image Gallery

0 Replies
64 Views
Last post September 15, 2018, 02:52:57 AM
by quaz0r
clip
Resolution Issue ?

Started by MonkeyDogBoy on Mandelbulber

2 Replies
311 Views
Last post February 19, 2018, 12:38:20 AM
by Tas_mania
xx
Possible issue with cancelled attached pics ?

Started by FractalDave on Forum Help And Support

0 Replies
57 Views
Last post December 20, 2018, 03:46:01 AM
by FractalDave
clip
Quaternion

Started by Bill Snowzell on Fractal Image Gallery

0 Replies
137 Views
Last post January 02, 2018, 10:11:34 PM
by Bill Snowzell