Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => (new) Theories & Research => Topic started by: Mrz00m on February 24, 2012, 01:21:36 PM




Title: different type of Hybrid mix... is it possible to do?
Post by: Mrz00m on February 24, 2012, 01:21:36 PM
I had a graphics program where i mixed formulas with a custom crossfading curve that mixes a varying gradient of colors, zooms, movements, rotations etc, together at different points.

Can you please help me make write this formula for 3d fractals to mix for example a bulb and a box so that 1 end is 100% box, the other is 100% bulb? i dont understand the 3d code very well.

has it already been done?

What global variables of a fractal can you mix together to make them combine? z.x,x.y,z.z?

here is a pic of the idea, although you could also just use a straight crossfade line along the X axis to mix the 2 together, rather than a sine curve, it would be faster.



Title: Re: different type of Hybrid mix... is it possible to do?
Post by: DarkBeam on February 24, 2012, 05:14:04 PM
It is not so easy. Doable with a little math knowledge.

Think of a function with those requirements

F(0) = 0
F(1) = 1

Then you might want;

F'(0) = 0
F'(1) = 0

To make a smooth passage. :) To do this use this system;

F(x) = a x^4 + b x^3 + c x^2 + d x + e
F'(x) = D(F(x),dx) = 4a x^3 + 3b x^2 + 2c x + d

And solve the linear system ;D (maybe I used too many terms, forgive me :embarrass: )
Then you need to truncate F ( if x<0, let F=0 anf if x>1, let F=1)

Fractal 1 is F1(x,y,z), Fractal 2 is F2(x,y,z)
Finally, at each pixel (x,y,z) = F1(x,y,z) * F(d) + F2(x,y,z) * (1-F(d))

Where d is a reasonable function of x,y,z like sqrt(x^2+y^2+z^2) or max(x,y,z) or whatever :dink:

A variation, you might want a function with those features;

F(0) = 0; F'(0) = 0; F( infy ) = 1

To do this you can use a fractionary function. :) (a1 x^n + b1 x^(n-1) + ...) / (a2 x^n + b2 x^(n-1) + ...)

I usually find coeffs by attempts because it's harder to derive those monsters :snore:

Else, you can use the same exact F as before but with a d = 1 - 1 / (1 + d) when you are sure that d >= 0


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: fractower on February 24, 2012, 09:31:12 PM
I have used a Gaussian partition function in the past. It does not have all the requested properties, but it is easy to implement and works for 2 or more fractal regions. Adopting DarkBeam's notation imagine you have two fractal functions F1 and F2 and you want F1 to dominate in the positive X direction and F2 to dominate in the negative X direction.

Create a measures of how close to the point being evaluated is to each region of influence.
d1 = |C - (1,0,0)|
d2 = |C - (-1,0,0)|

Calculate the mix of the fractal functions.
Z_new = (F1(Z)*exp(-a1*d1^2) + F2(Z)*exp(-a2*d2^2)) / (exp(-a1*d1^2) + exp(-a2*d2^2))

a1 and a2 determine how sharp the transition is. Using a value between 4 and 10 is a good start.



Title: Re: different type of Hybrid mix... is it possible to do?
Post by: DarkBeam on February 25, 2012, 12:14:15 AM
exp is a lot slower, but also nice, try both solutions :)


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: kram1032 on February 25, 2012, 01:43:08 AM
You can achieve "infinitely smooth" fading by using something like
Interpolatea,b(x) :=

0
[x <= a]
1/2 (1 + tanh((sqrt(3)/4) ((a - b) (a + b - 2 x))/((a - x) (-b + x))))
[a < x < b]
1
[x >= b]
As an interpolation function.

If you want interpolation between two functions f1 and f2, make it:

f1 (1-Interpolatea,b(x))+f2 Interpolatea,b(x)

The Sqrt(3) is just a choice to make the middle part of that function increase as smoothly as easily possible. The otherwise fourth order 0 accelleration at x=(a+b)/2 becomes fifth order by doing so.

Interpolate0,1(x) simplifies to:

0
[x<= 0]
-here only the first function will be taken
1
[x >= 1]
-here only the second function will be taken
1/2 (1 + tanh[(sqrt(3)/4) ((1 - 2 x))/( (-1 + x) x)])
[0 < x < 1]
-here is a smooth, infinitely continuous blend between the two functions

(http://puu.sh/ifc4)


Possibly, exponential functions are slightly faster and/or more numerically stable than hyperbolic tangent functions. In that case, you might want to use:
1 - 1/(1 + e(Sqrt(3) (a - b) (a + b - 2 x))/(2 (a - x) (-b + x)))
and for the 0-1 range,
1 - 1/(1 + e(Sqrt(3) (1 - 2 x))/(2 (-1 + x) x))
respectively.

More generally, you can have functions of the form:
1/2 (1+tanh(p(x)/q(x))) with p and q being aribitary polynomials. (rational functions)
If you choose such a rational function that goes to -infinity at x=a and to +infinity at x=b and is monotonic in the interval in between, you can get all kinds of interpolatory behaviour that, if you don't happen to choose the infinite polynomial series of the arcus tangens hyperbolicus arctanh, you almost certainly get a function that smoothly goes 0 to 1 in the interval [a,b] but does so infinitely smoothly at the limits of a and b.

Possibly even nicer from interpolatory point of view, however slightly more timeconsuming for containing a squareroot, might be this one:
(http://puu.sh/ifpZ)
with the exponential form
1 - 1/(1 + e(sqrt(3/2) (-1 + 2 x))/sqrt(-(-1 + x) x))
and its aribitary interval counterpart:
1/2 (1 + tanh((sqrt(3/2) (a + b - 2 x))/(2 (a - b) sqrt(((a - x) (-b + x))/(a - b)2))])

And IT's Exponential form:
1 - 1/(1 + e(sqrt(3/2) (a + b - 2 x))/((a - b) sqrt(((a - x) (-b + x))/(a - b)2)))

Again, the factor sqrt(3/2) is merely a choice to maximise the smoothness of the function around its interpolatory center and dropping another derivative order to 0 at that point.

Here a final comparison:
(http://puu.sh/ifwT)
the blue and purple functions are the ones proposed in this post.
The yellowish one is what linear interpolation does and the green one is what you proposed yourself based on a sine.
And here a closeup of the last 10% of the interpolation:
(http://puu.sh/ifzG)
In this region, the first function already is nearly flat while the others clearly are far away from it. You can see that the second function actually overtakes the sine at the edge of the 95% mark and ends up becomming just as flat as the first function, but does so much later.
The sine function lacks perfect smoothness in the endpoints (in the sense that the differentials wont go to all 0 at those points) eventhough it passes through the desired endpoint.

Just as a1 and a2 in fractower's variant, a and b in my variant determine the sharpness of the interpolation or alas the the quickness of the function to rise at the center.
Additionally, they define the location of the interpolation in case you don't want to interpolate the points 0 - 1 but rather, say, the points -3 - 1.5

by simply using this on a vector valued function, e.g.

f1 (1-Interpolate0,1(t))+f2 Interpolate0,1(t)
with
f1 and f2 being functions in x,y,z coordinates, you can use this without any change in 3D. Just apply per coordinate.


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: Mrz00m on February 25, 2012, 06:10:17 PM
oh! i didnt realise it was so complicated! i thought it would be ok to just encapsulate the values of both fractals and give them an index rating based on the smooth fading curve.

Thanks for the fading curve functions, very interesting! i generally use just sines, sqrt and exp of the sine to the sine's profile, but these functions are very intersting!

ok i will read about the derivations and gaussian fct's! sounds pretty intense, will have to cogitate for a while about all that!  :tongue1:


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: DarkBeam on February 25, 2012, 07:30:09 PM
Don't expect revolutionary fractals... Everytime you use interpolations the results tend to be weird, regardless of the function you chose :snore:


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: kram1032 on February 25, 2012, 08:52:02 PM
As long as you don't take "weird" as an equivalent to "boring", I don't really see how that'd be a bad thing :)


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: DarkBeam on February 25, 2012, 10:38:40 PM
As long as you don't take "weird" as an equivalent to "boring", I don't really see how that'd be a bad thing :)
I also made a smooth amazing box using some polynomial expressions (no exp) ... Not weird but it is another thing ;)
and a smooth passage julia mandelbrot but nobody uses it. ;)


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: cKleinhuis on February 26, 2012, 04:28:42 AM
yay, lets explore the simple types first, and discuss them then flavour in some more ... :D


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: cKleinhuis on February 26, 2012, 04:30:22 AM
you know, hybrid methods using alternation makes it possible to introduce endless parameters in a single formula ?
affecting only deeper and deeper iterations, but the seed can be different for each iteration step ;)


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: fractower on February 26, 2012, 05:57:05 AM
I had played with spatially separated hybrid bulbs at some point. The links include mandelbulber code if you want to give them a try.

One that worked.
http://www.fractalforums.com/index.php?action=gallery;sa=view;id=6548 (http://www.fractalforums.com/index.php?action=gallery;sa=view;id=6548)

One that didn't.
http://www.fractalforums.com/index.php?action=gallery;sa=view;id=6519 (http://www.fractalforums.com/index.php?action=gallery;sa=view;id=6519)


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: DarkBeam on February 26, 2012, 10:26:24 AM
I cannot resist hijacking;

Kali Abox with a dual Julia seed on and off a sphere :D (in the middle it's interpolated)

Change "shape" control and seeds to see more


Mandelbulb3Dv17{
X.....S....O/...w....2....UBxQUDjix9.L4KIu3p9L5EivbhY8lLVzHVTLkUheMEzS8iIckpdJ/k
................................N8tDre1CMz1........Y./..................y.2.....
................/M.0/.....U./...k1....E2.....wyz.k5nEUsD/..........m/dkpXm1....U
z.....kD12../2E3yLXVpCwqzWwddT.TIFzDcIdHNwdlbz9............u1....y1...sD...../..
.w1...kD451ztlA26y1..........KEjtGGvqCfjR5CJe2b7UrfllkTSA1/WzQlLGAGvqCfjJwZ2Xoih
nu1.xa97hPvgy2uMrT5nEUsD......o3..............kD.2....sD.2kz0...................
.............oAnAr1...sD....zU/St4.isZP.MZLi/UTSt4.auZP.sgLi/UxSt4......N....k1.
..................kz.wzzz1.U..6.P....M4...EB....W....k1....F....8/...I1.....UN52
...U.qFG9yzb2zzzRYoWzz7lz16.mc..zXCc..k18XGQeGyD/sIRhrVAkz1..........2.28.kFrA0.
.Ub96aAIVz9.1se7Umvxz0........../6U0.wzzz1................................E.0c..
zzzz.................................2U.8.kzzzD.................................
/6U0.wzzz1...................................2CcN/UvNP6.eeWCNq0.yRii.EJJUk1f..XR
S1.mx3CcN/UvNP6.QsLsUa3.ibhV..bTV1OK.sSq40.ly3CcN/UvNP6.MwLsUa3.ibhV.kqTV1OK.sSq
40.kz3CcN/UvNP6...EsUa3.eeWCNq0.IJ36wk8.wyLsUa3.................................
E....6....E.....I....g....kLE3aQolKS8J5Pd3aI....................................
0.U.......UaNaNaNaNmz........UzD........kzPnAnAnAnA4./.......EyDbNaNaNaN4.2.....
..k..NaNaNaNadyj................................................................
.....................2.....3....3....2YEjVLHjFqGVlKO............................
.QU1.........................UzDnAnAnAnAXzXNaNaNaNavzMaNaNaNaNxDaNaNaNaNqz1.....
................................................................................
................................}

 :beer:


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: kram1032 on February 26, 2012, 10:55:23 AM
Dark Beam, is there an image of that too?


Title: Re: different type of Hybrid mix... is it possible to do?
Post by: DarkBeam on February 26, 2012, 11:58:51 AM
Dark Beam, is there an image of that too?

Not that good but ...