Logo by Pauldelbrot - 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 the official fractalforums.com Youtube Channel
 
*
Welcome, Guest. Please login or register. February 23, 2020, 02:48:07 AM


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: Small trick for Ultra Fractal formulas/colourings  (Read 1579 times)
0 Members and 1 Guest are viewing this topic.
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« on: March 31, 2009, 01:46:03 AM »

Hi,

Ever wanted to pass more than just the z value from a formula to a colouring in Ultra Fractal ?

Well here's a way to do it - it's not perfect as it's a bit restrictive, is a noticeable overhead if used too much and degrades the accuracy of the z value concerned when used and requires that both the formula and colouring concerned understand what's going on *but* when needs must....

This is what I've used for passing a bailout type from a formula to a colouring - (integer) range 0 to 200 (max. possible range as implimented below 0 to 255) - I used it to pass the bailout type as part of the initial z value (I wanted the colouring to know the bailout type before iterating because the colouring has separate options for divergent/convergent/periodic and knowing the bailout type first avoids calculating for all possibilities).

Formula:-

; store the bailout type in #z
    float m = abs(real(#z))/512.0 ; scale by 512
    if m<1e-200 ; make sure it's not zero (so that the log works)
      m = 1e-200
    endif
    m = m + (bailout+256)*2.0^(ceil(log(m)/log(2.0))) ; add 256 to value
    if real(#z)<0.0
      m = -m
    endif
    #z = m + flip(imag(#z))

Colouring:-

; recover the bailout type and original value of #z
    float m = abs(real(#z))
    int n = 2.0^ceil(log(m)/log(2.0)-9) ; -9 as 512 is 2^9
    int k = floor(m/n)
    m = 512.0*(m - n*k) ; scale by 512
    bailout = k - 256 ; remove the 256
    if real(#z)<0.0
      m = -m
    endif
    #z = m + flip(imag(#z))

Obviously you could do a similar thing to pass a different value as part of imag(z) - or reduce the loss of accuracy in the z value by splitting your extra value between real(z) and imag(z).

Note that the above allows passing a value from 0 to 255 which requires 256 adding to the value which means adjusting the real(z) value by 512 i.e. 2^9 hence the values used above.
For a range from 0 to (2^n)-1 you need to add 2^n to your value and scale by 2^(n+1).
Obviously it is possible to do it for reals instead of integers, you'd just have to convert them to integers of a given number of bits first and adjust the code to add your custom conversion float<>int.
« Last Edit: March 31, 2009, 01:52:55 AM 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
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #1 on: April 07, 2009, 01:25:48 AM »

I should add that there is another way that has less overhead in terms of rendering time but requires more user input - namely modifying the formula so that the "max iterations" value actually used by the formula is less than that defined by the user - eg. if it is effectively one less than the value defined in the standard UF "Maximum Iterations" field then the formula has one extra loop iteration free in which to pass any value it likes as the final z value to the colouring - of course this is still subject to the colouring understanding what the formula is doing.
Logged

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

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
I like Painterly fractals and Incendia seems to do the trick Meet & Greet PayPaul 1 897 Last post January 06, 2010, 06:20:49 PM
by Nahee_Enterprises
has anybody tried using ifs formulas with the mandelbuld/mandelbox formulas? 3D Fractal Generation cKleinhuis 4 4573 Last post May 05, 2010, 03:17:07 PM
by Power 8
Shark or Small Aircraft and how to describe it in fractal Help & Support Mustafa Umut Sarac 6 968 Last post June 05, 2012, 11:03:29 PM
by stereoman
Trick or Treat Land Images Showcase (Rate My Fractal) JoeFRAQ 4 528 Last post October 31, 2013, 06:15:49 PM
by JoeFRAQ
exact DE formulas and fractal types (new) Theories & Research TruthSerum 5 482 Last post June 13, 2015, 01:28:37 AM
by TruthSerum

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.529 seconds with 27 queries. (Pretty URLs adds 0.02s, 2q)