Browse Source

Another huge speed upgrade (Removed sqrt function which ran every iteration)

Stephen Downward 1 year ago
parent
commit
cc9d0f0a51
1 changed files with 4 additions and 2 deletions
  1. 4 2
      MandelbrotCalc/Form1.cs

+ 4 - 2
MandelbrotCalc/Form1.cs

@ -167,14 +167,16 @@ namespace MandelBrotCalc
167 167
			double Zr = 0;
168 168
			double Zrtemp = 0;
169 169
			double Zi = 0;
170
			while(Math.Sqrt(Zr * Zr + Zi * Zi) < 2)
170

171
			double tot = Zr * Zr + Zi * Zi;
172
			while (Zr * Zr + Zi * Zi < 4)
171 173
            {
172 174
                numRecursions++;
173 175
				Zrtemp = Zr * Zr + Creal - (Zi * Zi);
174 176
				Zi = 2 * Zi * Zr + Cimaginary;
175 177
				Zr = Zrtemp;
176 178
                if (numRecursions > totalIterations) return 0; //Convergent
177
            }
179
			}
178 180
			return (int)ConvertRange(0, colorScale, 0, 16777215, numRecursions);
179 181
        }
180 182