Fractrace.Formulas.Mandelbulb3DPow2 C# (CSharp) Method

Mandelbulb3DPow2() private method

Quadratische Version (ohne Winkel)
private Mandelbulb3DPow2 ( double ar, double ai, double aj, double ak, double br, double bi, double bj, double bk, long zkl, bool invers ) : long
ar double
ai double
aj double
ak double
br double
bi double
bj double
bk double
zkl long
invers bool
return long
        long Mandelbulb3DPow2(double ar, double ai, double aj, double ak, double br, double bi, double bj, double bk, long zkl, bool invers)
        {
            // Umbenennen in Mandelbulb3D Pow2 (sollte eigentlich die Erweiterung des Mandelbulb sein).
            double xx, yy, zz;
            long tw;
            int n;
            ai = 0; aj = 0; ak = 0;

            double x = ai, y = aj, z = ak;

            xx = x * x; yy = y * y; zz = z * z;
            tw = 0L;
            double r = Math.Sqrt(xx + yy + zz);

            for (n = 1; n < zkl; n++)
            {
                double r_xy = Math.Sqrt(xx + yy);
                double a = 1;

                if (r_xy != 0.0)
                    a = 1 - zz / r_xy;

                y = 2 * x * y * a + br;
                x = (xx - yy) * a + bi;
                z = 2 * z * r_xy + bj;

                xx = x * x; yy = y * y; zz = z * z;// aak = ak * ak;
                r = Math.Sqrt(xx + yy + zz);

                if (r > gr)
                {
                    tw = n; break;
                }

            }

            if (invers)
            {
                if (tw == 0)
                    tw = 1;
                else
                    tw = 0;
            }
            return (tw);
        }