Welcome to Fractal Forums

Fractal Software => 3D Fractal Generation => Topic started by: knighty on April 23, 2010, 06:00:14 PM




Title: Mandelbox size
Post by: knighty on April 23, 2010, 06:00:14 PM
Hi, (maybe you already know this)
This is the formulas I've found about the size of the mandelbox and juliabox:
For the mandelbox, when scale >1, the size is proportionnal to:
      (scale+1)/(scale-1)

Say mandelboxDE(x,y,z,scale) is the function that gives the distance estimate at (x,y,z), and:
      factor= 2 if(scale<-1) and 2*(scale+1)/(scale-1) if(scale>1)
The scaled distance estimate will be:
      mandelboxDE(x*factor,y*factor,z*factor,scale)/factor
Proceeding this way will give a mandelbox centered at te origin with size 2x2x2.

In the case of juliabox, the size is propotionnal to:
       (abs(scale)+1)/(abs(scale)-1)
Using:
       factor=2*(abs(scale)+1)/(abs(scale)-1)
Will give a juliabox which is always inside the [-1,1]^3 box if the seed value is inside the corresponding mandelbox.


Title: Re: Mandelbox size
Post by: David Makin on April 23, 2010, 07:56:28 PM
I didn't :)

Thanks for that - but what about when you change the folding parameters (both rectangular distances and spherical radii) ?

I gave up on trying to work it out and did a sort of pre-render to get the values. I'm glad I did because I'm going to expand its usefulness so it can automagically set the appropriate step scale according to how accurate the DE is for a particular fractal (of any type, it can already suggest appropriate values for each Mandelbox/Juliabox).



Title: Re: Mandelbox size
Post by: knighty on April 23, 2010, 09:59:25 PM

but what about when you change the folding parameters (both rectangular distances and spherical radii) ?


According to my experiments, the proportionality factor ( (scale+1)/(scale-1) ) still holds. it depends only on the scale of the mandelbox. The spherical folding don't change anything but the size change with the parameter of the box folding. If 'a' is the parameter of the box folding ( I use : if(x>a) x=2*a-x; else if(x<-a) x=-2*a-x; and so...) the scaling factor should be:
      factor= 2*a if(scale<-1) and 2*a*(scale+1)/(scale-1) if(scale>1)
in order to keep the mandelbox in the [-1,1]^3 box.


I gave up on trying to work it out and did a sort of pre-render to get the values. I'm glad I did because I'm going to expand its usefulness so it can automagically set the appropriate step scale according to how accurate the DE is for a particular fractal (of any type, it can already suggest appropriate values for each Mandelbox/Juliabox).


How do you determine the appropriate step scale? I'm curious :)


Title: Re: Mandelbox size
Post by: David Makin on April 23, 2010, 11:06:13 PM
How do you determine the appropriate step scale? I'm curious :)

The routine I use starts with a grid of points to get the DE for (based on initial user parameters) - the square grid is a flat plane 11 points square such that it stretches say 40*40 units and it starts 40 units from the user-specified fractal centre (normally (0,0,0)) - the grid plane being perpendicular to the line through it's initial centre and the specified fractal centre.
It calculates the DE for all points on this grid, takes the minimum value then steps a small distance in the direction from the initial grid centre to the fractal centre reducing the grid size and centring the grid (2d-wise) on the point where it found the minimum DE value last time.
It then recalculates the DE for the new set of 11*11 points and again takes the minimum. Now we have two DE values a known distance apart and (assuming that our DE calculation is correctly linear) we can work out what our correct DE scale should be.
This process is essentially repeated at steps closer and closer to the fractal, always taking the point on the grid that gives the minimum DE value as the centre of the grid for the next step and refining the scale factor. We stop when the "correct" DE value is less than the user-specified DE threshold.
Finally we assume our last value is "correct" and check values at specified distances away back along the vector which the grid travelled on i.e. we check points that are supposed to be 1e-1, 1e-2, 1e-3, 1e-4.... down to the threshold*10 and for each of these check the *maximum* error factor (values less than the "correct" distance can be ignored) which gives us a scale factor for converting our DE to an actual step value, though in practice at the moment I deliberately double the value because I haven't finished tweaking the pre-render algorithm yet, it's just WIP at the moment. (note - double the value because I use step = DE/scale).
Note that the current version uses a grid from directions +x,-x,+y,-y,+z and -z i.e it repeats the process from 6 directions.

If that's too confusing then you'd probably follow better by just looking at the code - the basic routine is the "func MJBox" near the start of my wip3D5 formula for UF.

I'm aiming to expand and refine the routine so it can get "correct" DE scales and step scale adjustments for the delta DE methods as well - and so it works with just about any fractal type.

Note that the theory behind it is that the point it settles the grid on will always be a projecting point i.e. on a convex area of the fractal, therefore it should work for the delta DE methods without contamination due to the directional nature of the delta DE.


Title: Re: Mandelbox size
Post by: David Makin on April 23, 2010, 11:18:06 PM
( I use : if(x>a) x=2*a-x; else if(x<-a) x=-2*a-x; and so...)

I allow:

            if zbx>@xmax
              zbx = @xmax1 - zbx
            elseif zbx<@xmin
              zbx = @xmin1 - zbx
            endif
            if zby>@ymax
              zby = @ymax1 - zby
            elseif zby<@ymin
              zby = @ymin1 - zby
            endif
            if zbz>@zmax
              zbz = @zmax1 - zbz
            elseif zbz<@zmin
              zbz = @zmin1 - zbz
            endif

i.e. the comparison and sum need not match :)


Title: Re: Mandelbox size
Post by: knighty on April 24, 2010, 06:17:43 PM
Thanks for the explanations. I'll also take  look at your code.
( I use : if(x>a) x=2*a-x; else if(x<-a) x=-2*a-x; and so...)

I allow:

            if zbx>@xmax
              zbx = @xmax1 - zbx
            elseif zbx<@xmin
              zbx = @xmin1 - zbx
            endif
            if zby>@ymax
              zby = @ymax1 - zby
            elseif zby<@ymin
              zby = @ymin1 - zby
            endif
            if zbz>@zmax
              zbz = @zmax1 - zbz
            elseif zbz<@zmin
              zbz = @zmin1 - zbz
            endif

i.e. the comparison and sum need not match :)

Well, this introduces discontinuities in general. That's why I don't use it (yet).


Title: Re: Mandelbox size
Post by: David Makin on April 25, 2010, 01:46:01 AM
I should also add that I have the rectangular/spherical folding and scale in a repeat loop so that they can be applied multiple times as an overall transform before adding the constant - this also changes the box size and DE scaling, though I suspect in a defineable manner given your information.