Welcome to Fractal Forums

Fractal Software => Help & Support => Topic started by: crotafang on May 04, 2010, 12:43:54 AM




Title: Trying to Make an Apophysis Mandelbulb Script
Post by: crotafang on May 04, 2010, 12:43:54 AM
Hello all,

I'm new to Apo scripting, and I've started practicing scripting in Apophysis 7X.

I remember seeing the formulas for the Mandelbulb.  And I know it sounds crazy, but I have been trying to see if I can make a Mandelbulb script in Apophysis.  It's been difficult so far, and what I've done so far only freezes Apo.  :embarrass:  Here's what I've got so far:

with Transform do
begin
A := 0 ;
Weight := 0.5 ;
Color := 1 ;
end;       

x := 0;
y := 0;
z := 0;
r := sqrt(x*x + y*y + z*z);
alpha := arctan2(sqrt(x*x + y*y), z);
beta := arctan2(y, x);       
mand := [x, y, z];
while (x*x + y*y + z*z < 2.0) do
begin
  newx := (r*r) * sin( alpha*2 + 0.5*PI) * cos(beta*2 +PI);     
  newy := (r*r) * sin( alpha*2 + 0.5*PI) * sin(beta*2 +PI);
  newz := (r*r) * cos( alpha*2 + 0.5*PI);
  mand := [(x*(x+y+z) + newx), (y*(x+y+z) + newy), (z*(x+y+z) + newz)];
end;                                                         

I think I divided by zero somewhere and I don't know how to correct for that in Apophysis.  I know that basically, you have to have some sort of coordinate for when one of the valuables is zero, but I don't know how to properly do if, else statements in Apo scripting.  Maybe I should try this in Apo 2.08 3D first.  (shrug) I don't know, what do you guys think?

Sincerely,
crotafang


Title: Re: Trying to Make an Apophysis Mandelbulb Script
Post by: cKleinhuis on May 05, 2010, 12:56:06 AM
as a starter, you could try out the far more simple mandelbox method as transformation ;)


Title: Re: Trying to Make an Apophysis Mandelbulb Script
Post by: crotafang on May 06, 2010, 04:01:07 AM
Alright then.  I'll do that.  And if and when I succeed, I'll post the result.


Title: Re: Trying to Make an Apophysis Mandelbulb Script
Post by: cKleinhuis on May 06, 2010, 09:56:49 AM
do that, i am excited :D


Title: Re: Trying to Make an Apophysis Mandelbulb Script
Post by: Dinkydau on July 01, 2010, 10:36:18 PM
Have you got something already? It would be awesome to use such a fractal in Apophysis.


Title: Re: Trying to Make an Apophysis Mandelbulb Script
Post by: crotafang on July 08, 2010, 08:46:55 PM
Well I tried to do a Mandelbox, and this is what I have so far.  It doesn't have "errors", but it doesn't yield a Mandelbox at all.  I got the formulas down, but I don't know how to properly apply them to the transforms.  I'm using the Apophysis scripting which used Scripter Studio, which is based on Pascal.
program mandelbox;

var r, m, x, y, z;
with transform do
begin
linear3d := 0.75;
for k := 1 to 100 do
r := 0.5;            
x := random;
y := random;  
z := random;  


v := [x,y,z];
v[0] := x;
v[1] := y;
v[2] := z;
m := x*x + y*y + z*z;                                      
for i := 0 to 2 do                        
  begin
  addtransform;
  with transform do
  begin
  for x := -100 to 100 do
  begin
  for y := -100 to 100 do
  begin
  for z := -100 to 100 do
  begin
    if (v[ i ] > 1) then                      
      begin                                
        v[ i ] := 2 - v[ i ];
        if m < r then m := m /(r*r);
        else if m < 1 then m := 1 /(m*m);
        for j := 0 to 2 do
        begin        
          v[j] := 2*v[j];
        end;
        AddTransform;
        with transform do
        begin
          linear3D := 0.75;
          Translate(v[0],v[1]);
          ztranslate := v[2];
        end;
      end;                            
    else if (v[ i ] < -1) then
      begin
        v[ i ] := -2 - v[ i ];
        if m < r then m := m /(r*r);
        else if m < 1 then m := 1 /(m*m);
        v := 2*m;
        for j := 0 to 2 do
        begin
          v[j] := 2*v[j];
        end;
        AddTransform;
        with Transform do
        begin
          linear3D := 0.75;
          Translate(v[0],v[1]);
          ztranslate := v[2];
        end;
      end;
  end;        
  end;
  end;
  end;
  end;
end;

How do I apply a mathematical formula to a transform?


Title: Re: Trying to Make an Apophysis Mandelbulb Script
Post by: Xazo-Tak on September 05, 2011, 11:39:11 PM
Can you put it into electricsheep? If so, I WANTS IT.


Title: Re: Trying to Make an Apophysis Mandelbulb Script
Post by: DarkBeam on January 05, 2012, 08:32:52 PM
Well Mandelbox looks awesome when it's solid, not faded away like in Apo flames. :dink: Also Apo's folds are probabilistic and you should do deterministic ones instead to make the shapes more clear