samples/mandelbrot: Taking out the sqrt()
authorJerome St-Louis <jerome@ecere.com>
Fri, 1 Apr 2016 22:42:41 +0000 (18:42 -0400)
committerJerome St-Louis <jerome@ecere.com>
Fri, 29 Apr 2016 16:27:01 +0000 (12:27 -0400)
- log(x^c) = c log(x) !!!!

samples/guiAndGfx/mandelbrot/mandelbrot.ec

index 18294c3..1c31cab 100644 (file)
@@ -31,15 +31,15 @@ void drawMandelbrot(Bitmap bmp, float range, Complex center, ColorAlpha * palett
          bool out = false;
          for(i = 0; i < nIterations; i++)
          {
-            double zm;
+            double z2;
             Z = { Z.a*Z.a - Z.b*Z.b, Z.a*Z.b + Z.b*Z.a };
             Z.a += C.a;
             Z.b += C.b;
-            zm = sqrt(Z.a * Z.a + Z.b * Z.b);
+            z2 = Z.a * Z.a + Z.b * Z.b;
 
-            if(zm >= 2)
+            if(z2 >= 2*2)
             {
-               ii = (double)(i + 1 - log(log(zm)) / logOf2);
+               ii = (double)(i + 1 - log(0.5 * log(z2)) / logOf2);
                out = true;
                break;
             }