Logo by mclarekin - 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: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. April 24, 2024, 04:25:13 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: different type of Hybrid mix... is it possible to do?  (Read 989 times)
0 Members and 1 Guest are viewing this topic.
Mrz00m
Fractal Lover
**
Posts: 204


« 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.



* sinewave.jpg (59.92 KB, 1000x1000 - viewed 99 times.)
« Last Edit: February 24, 2012, 02:21:08 PM by Mrz00m » Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #1 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. smiley 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 grin (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 wink

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. smiley (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
« Last Edit: February 24, 2012, 05:24:42 PM by DarkBeam, Reason: blah blah » Logged

No sweat, guardian of wisdom!
fractower
Iterator
*
Posts: 173


« Reply #2 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.

Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #3 on: February 25, 2012, 12:14:15 AM »

exp is a lot slower, but also nice, try both solutions smiley
Logged

No sweat, guardian of wisdom!
kram1032
Fractal Senior
******
Posts: 1863


« Reply #4 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




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:

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:

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:

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.
« Last Edit: February 26, 2012, 11:20:49 AM by kram1032 » Logged
Mrz00m
Fractal Lover
**
Posts: 204


« Reply #5 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!  tongue stuck out
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #6 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
Logged

No sweat, guardian of wisdom!
kram1032
Fractal Senior
******
Posts: 1863


« Reply #7 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 smiley
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #8 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 smiley
I also made a smooth amazing box using some polynomial expressions (no exp) ... Not weird but it is another thing wink
and a smooth passage julia mandelbrot but nobody uses it. wink
Logged

No sweat, guardian of wisdom!
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #9 on: February 26, 2012, 04:28:42 AM »

yay, lets explore the simple types first, and discuss them then flavour in some more ... cheesy
Logged

---

divide and conquer - iterate and rule - chaos is No random!
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #10 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 wink
Logged

---

divide and conquer - iterate and rule - chaos is No random!
fractower
Iterator
*
Posts: 173


« Reply #11 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

One that didn't.
http://www.fractalforums.com/index.php?action=gallery;sa=view;id=6519
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #12 on: February 26, 2012, 10:26:24 AM »

I cannot resist hijacking;

Kali Abox with a dual Julia seed on and off a sphere cheesy (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.....
................................................................................
................................}

 A Beer Cup
Logged

No sweat, guardian of wisdom!
kram1032
Fractal Senior
******
Posts: 1863


« Reply #13 on: February 26, 2012, 10:55:23 AM »

Dark Beam, is there an image of that too?
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #14 on: February 26, 2012, 11:58:51 AM »

Dark Beam, is there an image of that too?

Not that good but ...


* smooth.JPG (84.02 KB, 692x562 - viewed 80 times.)
Logged

No sweat, guardian of wisdom!
Pages: [1]   Go Down
  Print  
 
Jump to:  


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.172 seconds with 24 queries. (Pretty URLs adds 0.014s, 2q)