Logo by slon_ru - 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. January 09, 2026, 07:19:59 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 ... 3 4 [5] 6 7   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: Benesi "pinetree" (fold+bulb)  (Read 7184 times)
0 Members and 1 Guest are viewing this topic.
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #60 on: October 23, 2015, 03:01:28 PM »

My attempt at a modified pinetree, hmmm huh?  Will have to try harder sad

Code:
//benesiPineTree transform 3D
void benesiPineTreeTransform3D(const sTransformBenesiPineTree &benesiPineTree, CVector3 &z, CVector3 &c,int i, sExtendedAux &aux)
{
  if (benesiPineTree.control.enabled && i >= benesiPineTree.control.startIterations && i < benesiPineTree.control.stopIterations)
  {
    CVector3 temp = z;
    CVector3 start = z;
    CVector3 tempV1;
    CVector3 newZ;
    CVector3 tempV2;
    tempV1.x = start.x * 0.81649658092772603273242802490196 - start.z * 0.57735026918962576450914878050196;
    newZ.z = start.x * 0.57735026918962576450914878050196  +  start.z * 0.81649658092772603273242802490196;
    newZ.x = tempV1.x * 0.70710678118654752440084436210485 - start.y * 0.70710678118654752440084436210485;
    newZ.y = tempV1.x * 0.70710678118654752440084436210485 + start.y * 0.70710678118654752440084436210485;
    newZ.x = fabs(newZ.x);
    newZ.y = fabs(newZ.y);
    newZ.z = fabs(newZ.z);
    tempV1.x = newZ.x * 0.70710678118654752440084436210485 + newZ.y * 0.70710678118654752440084436210485;
    newZ.y = -newZ.x * 0.70710678118654752440084436210485 + newZ.y * 0.70710678118654752440084436210485;
    newZ.x = tempV1.x * 0.81649658092772603273242802490196 + newZ.z * 0.57735026918962576450914878050196;
    newZ.z = -tempV1.x * 0.57735026918962576450914878050196 + newZ.z * 0.81649658092772603273242802490196;
   
    start = benesiPineTree.scale * newZ - benesiPineTree.offset; // applying six variables:-  scale.x, scale.y, scale.z,  offset.x, offset.y, offset.z
   
   
    tempV2 = start * start;
    double tempD3 = 2.0 * start.x/sqrt(tempV2.y + tempV2.z);
    newZ.x= tempV2.x  -  tempV2.y  -  tempV2.z;


    newZ.z=tempD3 * (tempV2.y - tempV2.z); //y and z variables are switched to add symmetry
    newZ.y=tempD3 * 2.0 * start.y * start.z;
    z = newZ + c * benesiPineTree.constantMultiplier;// CVector3 individual values for c.x, c.y, c.z, so can use "0" to get rid of unwanted pixel additions




* MB6 uPT aaa3 439.jpg (214.42 KB, 800x600 - viewed 45 times.)
Logged
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #61 on: October 23, 2015, 07:08:03 PM »

Re-using variables is very bad for code readability/clarity, and doesn't result in fewer registers being used or anything like that.

  My idea is to test whether there is a problem with the compiler using unnecessary registers or stack shifts, thus the streamlined code (which is harder to read.. but so what- this is just to test the compiler). 

  In other words, if the following code runs faster than the original code, you have a problem with the compiler using extra registers or stack movement due to the extra variables.  The test is easy.  Run this code.  Run the other code.  If one is measurably faster.....

Code:
[OPTIONS]
.Version = 2
.DEscale = 1
.SIpower = 2
[SOURCE]
procedure BenesiPineTree(var x, y, z, w: Double; PIteration3D: TPIteration3D);
var
  scale, offset: Double;
  sqrt_1_2, sqrt_1_3, sqrt_2_3: Double;
  x_temp, y_temp, z_temp, temp: Double;   

begin
  scale := 2.0;     
  offset := 2.0;

  sqrt_1_2 := 0.7071067811865475;
  sqrt_1_3 :=  0.5773502691896258;
  sqrt_2_3 := 0.816496580927726;   

   
  x_temp := x*sqrt_2_3 - z*sqrt_1_3;
  z :=  x*sqrt_1_3 + z*sqrt_2_3;
  x := x_temp*sqrt_1_2-y*sqrt_1_2;
  y := x_temp*sqrt_1_2+y*sqrt_1_2;

  x := abs(x);   // can you do this above?  I don't know how tight the compiler is
  y := abs(y);   // so if it's moving the stack and registers around before it does these commands
  z := abs(z);   // it might be faster to do the abs()  command up above, instead of here

  x_temp := x*sqrt_1_2 + y*sqrt_1_2;
  y := -x*sqrt_1_2 + y*sqrt_1_2;
  x := x_temp*sqrt_2_3 + z*sqrt_1_3;
  z := -x_temp*sqrt_1_3 + z*sqrt_2_3;

  x:=scale*x-offset; //scale =2 offset=2
  y:=scale*y;
  z:=scale*z;

  x_temp:=x*x;
  y_temp:=y*y;
  z_temp:=z*z;
  temp:=2.0*x/sqrt(y_temp+z_temp);


  x:= x_temp - y_temp - z_temp + PIteration3D^.J1;   
  y:=temp*2.0*y*z; 
  z:=temp*(y_temp-z_temp);
 
end;
[END]

Description:
...
Logged

M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #62 on: October 23, 2015, 07:14:22 PM »

An assembly formula is never readable nor reusable wink
  lol...
Logged

M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #63 on: October 23, 2015, 07:20:56 PM »

Hi, thanks for the comment, but please note, that for me performance at this step of development was not important (except for those obvious things like precalculating constants), the main achievement was to make this formula to work at all... and getting the same result cheesy
  Cool.  Awesome that you got it to work!

  I was thinking that maybe using the 2 different codes would show whether there is an optimization bug associated with variable usage (to be fixed later). 
Logged

thargor6
Fractal Molossus
**
Posts: 789



WWW
« Reply #64 on: October 23, 2015, 10:04:24 PM »

   In other words, if the following code runs faster than the original code, you have a problem with the compiler using extra registers or stack movement due to the extra variables.  The test is easy.  Run this code.  Run the other code.  If one is measurably faster.....
The "optimized" code runs slightly slower, but more importantly, it does not lead to the same result ;-)
Logged
thargor6
Fractal Molossus
**
Posts: 789



WWW
« Reply #65 on: October 23, 2015, 10:16:37 PM »

Btw, I like this formula a lot (still using my first "slow" version):
Logged
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #66 on: October 23, 2015, 11:49:39 PM »

The "optimized" code runs slightly slower, but more importantly, it does not lead to the same result ;-)

lol!@#   My anti-optimization powers strike again!  cheesy  

  The result difference is because I took out the y and z pixel additions.  


  Cool looking image!  Organic.  nice. 
Logged

M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #67 on: October 24, 2015, 01:37:58 AM »

here. 

Transform 3 is sort of like transform 2, use ~1.414 scale and offset for it.  I'll post images later.  It's a bit different. 

Code:
[OPTIONS]
.Version = 2
.DEscale = 1
.SIpower = 2
.Double Scale = 1.414    //no.. it is not square root of 2.  Seriously.  I wouldn't lie to you.
.Double xOff = 1.414   //  there is no such thing as mathematical sarcasm.
[CONSTANTS]
Double = 0.816496580927726
Double = 0.5773502691896258
Double = 0.7071067811865475
[CODE]
558BEC81EC300000005356578B75088B7E308BD8D9D0DD03DC0FDD01DC4F08D9
E0DEC1DC4F10DD5DF8DD02DC4F10DD1A90DD03DC4F08DD01DC0FDEC190DD45F8
DC2290DD45F8DC0290D9E1DD5DF0D9E1DD5DF8D9E1DD19D9D0DD45F0DC01
DC67E8D9E1DC4FF0DC4F10DD1B90DD45F8DC01DC67E8D9E1DC4FF0DC4F10
DD1A90DD45F8DC45F0DC67E8D9E1DC4FF0DD1990DD02DC03DD02DC23DD1A
DD5DF890DD45F8DC0FDD01DC4F08DEC1DD45F8DC4F08D9E0DD01DC0F90DEC1DD
19DD1B90D9D08BC35F5E5B89EC5DC20800
[END]


Description:

The cool Benesi pinetree formula. Use in conjunction with normal
 BenesiPine1 or it is messy!
Or any other formula :)
(Three iters of pine1 + one of pine2)

// STEP1: "Benesi fold 3"
tx=(x*sqrt(2/3)-z*sqrt(1/3))*sqrt(1/2);
y=y*sqrt(1/2);
z=abs(x*sqrt(1/3) + z*sqrt(2/3));       //replace squaring with abs    D8C8 to  D9E1   done
tx=abs(tx-y);          //replace squaring with abs    D8C8 to  D9E1   done
ty=abs(tx+y);       //replace squaring with abs    D8C8 to  D9E1   done

x=abs(ty+z-offset2)*scale2*sqrt(1/2) ;  //remove sqrt part for these three   done
y=abs(tx+z-offset2)*scale2*sqrt(1/2) ;   //
z=abs(tx+ty-offset2)*scale2 ;    //

tx=y+x; y=y-x;
x=z*sqrt(1/3)+tx*sqrt(2/3);    //
z=z*sqrt(2/3)-tx*sqrt(1/3);    // 


[/code]
Logged

M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #68 on: October 24, 2015, 06:00:26 AM »

And.. silly me.  I finally understand how to use M3D....  embarrass embarrass embarrass

   Finally made my first official pine tree combo in M3D!#!!!:



Code:
Mandelbulb3Dv18{
g.....s/...c3...w....2.....qgGqbq9Jxz8k7.8K6JA2EQOmvmJrojz93xENw05CpzaOoO35E..yD
................................PQmj9H0S/.2........A./..................y.2...wD
...Uz6.....c0.../M.0/.....kf....//....E3.....2B2wllgi0oD/..........m0dkpXm1....U
./....kD12../..........wz.................................U0.....y1...sD...../..
.z1...sD2iG9ULnFTx1mfy826hJBzoHTbqMrUGoj6HQUgZVsZwXAZ3up1YKKzM5RdsAtmJpDW2C40nmY
4x1SpJd8qDDJzageHU16WRpDU.....Iy1.............sD.6....sD..G.....................
.............oAnAt1...sD....z...........................................C....k1.
.....Ksulz1.......kz.wzzz1.U..6.P....U5...EB....m....c3....F....6/...I1.....SF52
...U.qFG9yzb2zzzRYoWzz7lz16.pc..zXCc..kvrEtMc7xD6ocyFE0ujz1..........2.28.kFrA0.
.Ub96aAIVz9.1se7Umvxz0........../EU0.wzzz1...........s/...................E.2c..
zzzz.............0...................2./8.kzzzD............8....................
/EU0.wzzz1...................................2CcN/UvNPcveeWCNq0.yRiibHJJUk1f..XR
SvBmx3CcN/UvNPcvQsLsUa3.ibhVi1bTV1OK.sSq4uCly3CcN/UvNPcvMwLsUa3.ibhVinqTV1OK.sSq
4uCkz3CcN/UvNPcv..EsUa3feeWCNqGQIJ36wk8EwyLsUa3f................................
E.E..I.//3./....I....6....UEZtKNnZ4IdtKNlsqPNd3.................................
...................../.........E................................................
................................................................................
.....................2.....3....0....6INiJqQdFZQVtqQaxaQh71.....................
...............................E..........2.....................................
................................................................................
................................/....E/.........0JaPZBLOEZaPZVJKO/..gJKOY/......
..........................................2........../.................CD02.....
.UnX.1.................CD02......UnX.1..........................................
..........................................E.....I....6....UEZtKNnZ4Jm3aPnNqPmpqA
..........................................kAnAnAnAnyzAnAnAnAngzD................
................................................................................
.....................................................2.....3....0....6INiJqQd/JO
iJKAixKKO/.....................................................E..........2.....
................................................................................
................................................................}
{Titel: doy}


  Attaching a few other formulas...  BenesiPine1noYZ... has noYZ components.  You don't have to cancel them out.  If you mix it with the first one Luca wrote (after a few iterations)... it gets sort of cool.

  hahhaa... Someone needs to make an animation.  If you do a rotation between the Mandelbulb part of the formula, and the transform part, after a certain iteration, it only rotates certain things.  It's pretty cool...



* BenesiTransform3.m3f (1.33 KB - downloaded 30 times.)
* BenesiPine2noYZ.m3f (1.46 KB - downloaded 29 times.)
* BenesiPine1noYZ.m3f (10.48 KB - downloaded 33 times.)
Logged

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


Fragments of the fractal -like the tip of it


« Reply #69 on: October 24, 2015, 10:07:55 AM »

Message to Matthew
Please please open a topic with your m3f and put them all together in there (or a mass confusion is going to begin). Thanks smiley police
« Last Edit: October 24, 2015, 07:52:32 PM by DarkBeam » Logged

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



« Reply #70 on: October 24, 2015, 12:44:45 PM »

Quote
And.. silly me.  I finally understand how to use M3D...

Silly me. I just reread the whole post and I find I had some really mixed up ideas on the transforms smiley

Well done with getting it all working, it is a relief when you finely  get your transforms working. I find it incredible how many stupid mistakes I make, and everthy takes so much longer than I expect. smiley

Here is a minor optimization ( if you have not already done it) ,  y := x_temp*sqrt_1_2+y*sqrt_1_2;    reduces to      y :=( x_temp +  y )  * sqrt_1_2;      // you  delete 4 multiplications from your transform
Logged
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #71 on: October 24, 2015, 06:16:23 PM »

I'll check it... I cannibalized Luca's version of transform 2 to make transform 3, just removing 3 square root operations.

  Some of the math posted in this thread is not actually the way it is implemented in the code (some of the descriptions of the code (for the formulas!) contain errors. 
Logged

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


Fragments of the fractal -like the tip of it


« Reply #72 on: October 24, 2015, 07:53:17 PM »

Plz read my latest message above wink
Logged

No sweat, guardian of wisdom!
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #73 on: October 25, 2015, 02:00:47 AM »

hahahaha... Done.  Next up.. well, I should put it in that thread  (a few formulas for Luca thread is here).

 I'm thinking about a weighted transform, that smoothly transitions between T2 and T3.  So you could be 100 T2, or 99 T2 + 1 T3, or 35 T2 + 65 T3...  you get the picture.

  This will allow smooth transitions between stuff, such as the first image (which is pure T3, with 1 or 2 full pixel add ins, which give it a bit of distortion) to the next image (which... I think is T2 and T3??? with maybe... only pixel x??):
to

  Then when we mix in specific rotations (after transforms on specific iterations), we can move specific portions of it:
<a href="https://www.youtube.com/v/SXx36wiDpN0&rel=1&fs=1&hd=1" target="_blank">https://www.youtube.com/v/SXx36wiDpN0&rel=1&fs=1&hd=1</a>

  You can also distort it a bit by rotating around different axes (the video above is around the x axis after the transform).  
« Last Edit: October 25, 2015, 02:08:39 AM by M Benesi » Logged

mclarekin
Fractal Senior
******
Posts: 1739



« Reply #74 on: October 25, 2015, 02:09:13 AM »

Transition look at Mandelbulber common_math.cpp.

Code:
//Smooth transition between two vectors with vector length control
template <typename T>
T SmoothCVector(const T &v1, const T &v2, double k)
{
T result;
double nk = 1.0 - k;

if(k <= 0.0)
{
result = v1;
}
else if (k >= 1.0)
{
result = v2;
}
else
{
double length1 = v1.Length();
double length2 = v2.Length();
double lenInterp = length1 * nk + length2 * k;
T vTemp = v1 * nk + v2 * k;
double lengthTemp = vTemp.Length();
if(lengthTemp > 0.0)
{
result = (vTemp / lengthTemp) * lenInterp;
}
else
{
result = v1;
}
}
return result;


With it you can transition between any fractal or transform with good to average effect.  With it you can grow hybrid fractals. It is very cool for animation.

Can be used also to fine tune DE, i.e if adding a tranform into your loop that makes the DE bad, you can try reducing the weight and sometimes you still get a good effect but also your DE gets better.

With IFS you sometimes have to set it up so the weight also changes the DE calculation.
Logged
Pages: 1 ... 3 4 [5] 6 7   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.207 seconds with 24 queries. (Pretty URLs adds 0.013s, 2q)