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: Did you know ? you can use LaTex inside Postings on fractalforums.com!
 
*
Welcome, Guest. Please login or register. April 20, 2024, 02:38:30 PM


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: Smoothed MengerIfs  (Read 3290 times)
0 Members and 1 Guest are viewing this topic.
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« on: October 25, 2015, 04:59:29 PM »

It is just an idea. Here is the original code.
Code:
Menger3(x,y,z){ // (c) knighty
   r=x*x+y*y+z*z;
   for(i=0;i<MI && r<bailout;i++){
      rotate1(x,y,z);

      x=abs(x);y=abs(y);z=abs(z); // abs
      if(x-y<0){x1=y;y=x;x=x1;} // swap 1
      if(x-z<0){x1=z;z=x;x=x1;} // swap 2
      if(y-z<0){y1=z;z=y;y=y1;} // swap 3
      
      z-=0.5*CZ*(scale-1)/scale;
      z=-abs(-z); // abs
      z+=0.5*CZ*(scale-1)/scale;

      rotate2(x,y,z);
    
      x=scale*x-CX*(scale-1);
      y=scale*y-CY*(scale-1);
      z=scale*z;
      
      r=x*x+y*y+z*z;
   }
   return sqrt(x*x+y*y+z*z)*scale^(-i);
}

To make a smoothed out version we must replace all swaps and abs() with smooth functions.
The trouble is smooth the swaps smiley
Defining this formula:
Code:
function s0(a) {return (a<0)?a:0;}
T=s0(x-y);
X=x-t;
Y=y+t;
It also does the trick.
Now defining...
Code:
function s1(a,b) {return (0.5*(a-sqrt(a*a+b)));} // b must be positive
T=s1(x-y,smoothfac);
X=x-t;
Y=y+t;
The bigger is the factor the smoother is the swap. Zero leads to the same result as the conditional swap. (Or it really should!)
As for smoothing abs you use sqrt(a*a+b) with the same meaning and precaution.
No renders for now cheesy anyone can try this?
Edit. Never mind. Fixed a stupid error
« Last Edit: October 26, 2015, 09:34:51 AM by DarkBeam, Reason: X - y fuuu » Logged

No sweat, guardian of wisdom!
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #1 on: October 25, 2015, 05:46:49 PM »

Function plot using Google...
https://www.google.it/search?q=sqrt(x)&sourceid=chrome-mobile&ie=UTF-8#q=(-sqrt(x*x%2B40)%2Bx)%2F2
Logged

No sweat, guardian of wisdom!
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #2 on: October 26, 2015, 12:40:15 AM »

 afro

I still have an infinity of coding to do, in exploring all the links you have already supplied me with. grin
Logged
thargor6
Fractal Molossus
**
Posts: 789



WWW
« Reply #3 on: October 26, 2015, 01:21:41 AM »

No renders for now cheesy anyone can try this?
Just released an ALPHA-version of the JIT-version ( http://www.fractalforums.com/beta-testing/experimental-mb3d-version-with-integrated-formula-compiler-(jit)/ ). Maybe you can hack it together by yourself cheesy
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #4 on: October 26, 2015, 07:52:54 AM »

Great Andreas and good luck Mc! angel
Logged

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


formerly known as 'Trifox'


WWW
« Reply #5 on: October 26, 2015, 09:09:55 AM »

nice experiment alex, very nice to see you really continue the development, respects for that!

Logged

---

divide and conquer - iterate and rule - chaos is No random!
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #6 on: October 26, 2015, 11:46:49 AM »

 grin grin grin

Delphi version of MengerIfs.

Code:
[OPTIONS]
.Version = 2
.DEscale = 1
.SIpower = 2
[SOURCE]
procedure MengerIFSsmooth(var x, y, z, w: Double; PIteration3D: TPIteration3D);
var
  t: Double;
  sc, sc1, sc2: Double;
  Cx, Cy, Cz: Double;

begin
  sc := 3.0;
  sc1 := sc-1.0;
  sc2 := sc1/sc;
  Cx := 1.0; Cy := 1.0; Cz := 0.5;
  t := 9999999.0;

  x := abs(x); y := abs(y); z := abs(z);

  If x-y < 0.0 then
  begin
    t:=x; x:=y; y:=t;
  end;
  If x-z < 0.0 then
  begin
    t:=x; x:=z; z:=t;
  end;
  If y-z < 0.0 then
  begin
    t:=y; y:=z; z:=t;
  end;

  z := z - Cz*sc2;
  z := - abs(-z);
  z := z + Cz*sc2;

  x := sc*x-Cx*sc1;
  y := sc*y-Cy*sc1;
  z := sc*z;
end;
[END]

Description:

Now on to the smooth one cheesy

WOAH!!! Works the wave the wave the wave

Code:
[OPTIONS]
.Version = 2
.DEscale = 1
.SIpower = 2
.DEoption = 2
[SOURCE]
procedure MengerIFSsmooth(var x, y, z, w: Double; PIteration3D: TPIteration3D);
var
  t: Double;
  sc, sc1, sc2: Double;
  Cx, Cy, Cz: Double;
  s: Double;

begin
  sc := 3.0;
  sc1 := sc-1.0;
  sc2 := sc1/sc;
  Cx := 1.0; Cy := 1.0; Cz := 0.5;
  t := 9999999.0;
  s := 0.005;

  x := sqrt(x*x+s); y := sqrt(y*y+s); z := sqrt(z*z+s);

  t:=x-y; t:= 0.5*(t-sqrt(t*t+s));
  x:=x-t; y:= y+t;

  t:=x-z; t:= 0.5*(t-sqrt(t*t+s));
  x:=x-t; z:= z+t;

  t:=y-z; t:= 0.5*(t-sqrt(t*t+s));
  y:=y-t; z:= z+t;

  z := z - Cz*sc2;
  z := - sqrt(z*z+s);
  z := z + Cz*sc2;

  x := sc*x-Cx*sc1;
  y := sc*y-Cy*sc1;
  z := sc*z;
  w := sc*w;
end;
[END]

Description:
« Last Edit: October 26, 2015, 11:59:36 AM by DarkBeam, Reason: deoption is correct now! THANKS ANDREAS » Logged

No sweat, guardian of wisdom!
thargor6
Fractal Molossus
**
Posts: 789



WWW
« Reply #7 on: October 26, 2015, 11:47:07 AM »

Delphi version of MengerIfs.
Nice  A Beer Cup

Btw, you may also use local functions here, would probably be a good approach to implement your s0/s1-function in this case, e.g.:
Code:
[SOURCE]
procedure MengerIFSsmooth(var x, y, z, w: Double; PIteration3D: TPIteration3D);
var
  t: Double;
  sc, sc1, sc2: Double;
  Cx, Cy, Cz: Double;

  function s0(const a: Double):Double;
  begin
    Result := ...
  end;

begin
  sc := 3.0;
  ...
end;
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #8 on: October 26, 2015, 08:55:47 PM »

Great idea Andreas; too bad I prefer a longer code for an easier asm transcription. smiley But you did a wonderful job. A Beer Cup
For the coders;
Also a different smoothing style is easily done. Replace all sqrt(t*t+s) occurrencies (also those with x y z keeping the appropriate symbols ...) with: abs(t)*t*t/(s+t*t) (unoptimized but you got the idea) wink
Logged

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

Related Topics
Subject Started by Replies Views Last post
Smoothed Julia Fractals Other Artforms Michael Scharrer 0 2434 Last post September 15, 2015, 08:36:52 AM
by Michael Scharrer
fixed TwistBraid tutorial (with MengerIFS) Mandelbulb 3d M Benesi 9 3380 Last post May 14, 2017, 01:06:59 AM
by 1Bryan1

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.141 seconds with 25 queries. (Pretty URLs adds 0.012s, 2q)