Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => The 3D Mandelbulb => Topic started by: asimes on March 02, 2012, 10:20:12 AM




Title: Triplex problem
Post by: asimes on March 02, 2012, 10:20:12 AM
I'm making a Mandelbulb in Processing and I have a version that works by using rotation with Spherical Coordinates and wanted to make one that works with triplex multiplication. So far I only tried doing a triplex version of z = z^2+c (instead of Mandelbulb z = z^8+c) but the result was a slightly 3D Mandelbrot (the sides have a round bulge). I apologize if there is a better name for this, but it is not the same as my result for the rotation method to the second power. I'll post images of both at the bottom.

I'm using this as reference: http://www.fractalforums.com/theory/triplex-algebra/

Specifically I thought I'd use this part:

{x1, y1, z1}*{x2, y2, z2} = {(x1*x2-y1*y2)*(1-(z1*z2)/(p1*p2)), (x2*y1+x1*y2)*(1-(z1*z2)/(p1*p2)), p1*z2+p2*z1}

p1 = sqrt(x1*x1+y1*y1)
p2 = sqrt(x2*x2+y2*y2)

I made the assumption that if (x1, y1, z1) is z then (x1, y1, z1) is equal to (x2, y2, z2) because I'm trying to square z. This is the section of my code that is supposed to be doing the z = z^2+c math:

Code:
float nx = x;
float ny = y;
float nz = z;
int n = 0;
while (n < maxIterations) {
  float p = sqrt(nx*nx+ny*ny);
  float tx = (nx*nx-ny*ny)*(1-(nz*nz)/(p*p));
  float ty = (2*nx*ny)*(1-(nz*nz)/(p*p));
  float tz = 2*p*nz;
  nx = tx+x;
  ny = ty+y;
  nz = tz+z;
  if (nx*nx+ny*ny+nz*nz > 4) break;
  n++;
}

Still working on rendering the points better... hopefully it is still obvious what fractals these are.

Result from rotation method at z = z^2+c and max iterations of 10:
(http://i.imgur.com/qISRe.png)

Result from triplex method at z = z^2+c and max iterations of 10:
(http://i.imgur.com/lPUHe.png)


Title: Re: Triplex problem
Post by: asimes on March 02, 2012, 10:08:19 PM
Ok, simpler question, is the section of that triplex math I took meant to be interchangeable with the rotation method of generating a Mandelbulb? I don't see any mistakes in my math... I just don't know all these terms and they are difficult to find with Google.


Title: Re: Triplex problem
Post by: cKleinhuis on March 02, 2012, 10:25:22 PM
your assumption is correct, but the multiplication is developed from the exponentiation, hence you just need to implement the exponentiation, which is the first
and i would suggest you include the exponentiation because of easier playing with other exponents

after you got this you just need the "+" operation which is standard vector math

and just remember, if z=0 it is standard complex algebra


Title: Re: Triplex problem
Post by: asimes on March 03, 2012, 01:49:51 AM
Ok, I understand what you mean about it being standard complex algebra if z = 0, I didn't notice that when I wrote it. I guess that explains how I got a "fat" Mandelbrot (if I rotate the image it bulges both directions along the z-axis).

Please forgive my lack of math knowledge, but which is the exponentiation one? The one that is after "The power formula is based on two consecutive rotations..."?

To be honest when I wrote the code for the non-trig one (what I posted earlier) I expected it to be a Mandelbulb at power 2 like my rotation method. I don't understand what I need to change to make the non-trig one work like the rotation method.


Title: Re: Triplex problem
Post by: cKleinhuis on March 03, 2012, 03:26:49 PM
yes, this is the exponentiation or power formula, a standard mandelbrot is retrieved when using "2" as "power"
both 3d fractals look rather disappointing in the power2 mode, and the original mandelbulb is a power8 mandelbrot
fractal
 
a good test if your formula is correct is to just render the z=0 plane, which should yield you then a mandelbrot,
then you just need to inspect the z= part of the formula to make it correct

both formulas yield mandelbrot shape in z=0 plane!

side note:
just to let you know what you are doing: the original bailout is sqrt(z)<4, you let the sqrt away, but it would be better
to use z<16 as bailout, because sqrt(16)=4, this way you can ommit the sqrt in the bailout test, or you know what
you where doing, then the 4 is fine because you experimented already with the bailout limit ;)


Title: Re: Triplex problem
Post by: asimes on March 03, 2012, 11:20:05 PM
Opps, thanks for catching that, I forgot to make 4 be 16 for the bailout. It seems to look just about the same as 16 but making it 4 wasn't intentional.

I think what I've been calling the "rotation method" is the exponentiation / power formula. It does correctly make a Mandelbulb if I set its power to 8 and it made the first image I posted (which is power 2). What I think I'm not getting is why the non-trig method made a different image (also at power 2). Is it supposed to make a different image?

Below is the point testing for the rotation method which I think is the exponentiation / power formula. It works correctly, but it depends on a lot of sqrt, atan2, sin, and cos. This is slow and why I wanted to make the non-trig code that would hopefully make the same images.

Code:
float rad = sqrt(x*x+y*y+z*z);
float phi = atan2(z, x);
float phiLength = sqrt(x*x+z*z);
float theta = atan2(phiLength, y);
float nx = x;
float ny = y;
float nz = z;
int n = 0;
while (n < maxIterations) {
  float nRad = sqrt(nx*nx+ny*ny+nz*nz);
  float nPhi = atan2(nz, nx);
  float nPhiLength = sqrt(nx*nx+nz*nz);
  float nTheta = atan2(nPhiLength, ny);
  nx = cos(nPhi*power)*sin(nTheta*power)*pow(nRad, power)+cos(phi)*sin(theta)*rad;
  ny = cos(nTheta*power)*pow(nRad, power)+cos(theta)*rad;
  nz = sin(nPhi*power)*sin(nTheta*power)*pow(nRad, power)+sin(phi)*sin(theta)*rad;
  if (nx*nx+ny*ny+nz*nz > 16) break;
  n++;
}

Sorry if I'm starting to drive you crazy with these clarifications but I don't understand if the non-trig code is supposed to make the same images as the exponentiation code. Are they supposed to make different fractals?


Title: Re: Triplex problem
Post by: cKleinhuis on March 04, 2012, 12:12:49 AM
the non trig is supposed to make the same image, just check your formula carefully, usually its just a sign +/- error, or something similar easy to overlook


Title: Re: Triplex problem
Post by: DarkBeam on March 04, 2012, 12:16:59 AM
Probably you did not change z's sign


Title: Re: Triplex problem
Post by: asimes on March 04, 2012, 08:15:09 PM
I finally got it! It smokes my exponentiation code speed wise :)

(http://i.imgur.com/fnnLc.png)
Code:
float nx = x;
float ny = y;
float nz = z;
int n = 0;
while (n < maxIterations) {
  float tx = (nx*nx-ny*ny)*(1-(nz*nz)/(nx*nx+ny*ny));
  float ty = 2*nx*ny*(1-(nz*nz)/(nx*nx+ny*ny));
  float tz = -2*nz*sqrt(nx*nx+ny*ny);
  nx = tx+x;
  ny = ty+y;
  nz = tz+z;
  if (nx*nx+ny*ny+nz*nz > 16) break;
  n++;
}

I found bugman's website that had a similar equation to the one I was using: http://bugman123.com/Hypercomplex/

Next step is to render it better and then do the triplex method for each increasing power up to 8. Thank you in particular to cKleinhuis for your patience helping out.


Title: Re: Triplex problem
Post by: cKleinhuis on March 04, 2012, 08:20:05 PM
congrats ;)