private void ThreadedIterate(System.Object obj) { FractalUtility.ThreadData td = (FractalUtility.ThreadData)obj; float xStep = (mMaxX - mMinX) / (mData.GetUpperBound (0) + 1); float yStep = (mMaxY - mMinY) / (mData.GetUpperBound (1) + 1); for (int y = td.start; y < td.end; ++y) { for (int x = 0; x <= mData.GetUpperBound (0); ++x) { if (mWorker.CancellationPending) break; FractalComplexNumber complexPoint = new FractalComplexNumber (mMinX + (x * xStep) - mCenter.x, mMinY + (y * yStep) - mCenter.y); float iterated = Iterate (complexPoint, new FractalComplexNumber (mInitialPoint)); float value = 1; if (iterated >= 0) { value = iterated; } mData [x, y] = value; } if (mWorker.CancellationPending) break; } mMutex.WaitOne (); mFinishedThreadCount++; mMutex.ReleaseMutex (); }
public static void QuadMandelbrotIterate(int iterations, out float returnVal, params FractalComplexNumber[] complexNos) { returnVal = -1f; FractalComplexNumber z = new FractalComplexNumber(); FractalComplexNumber c = complexNos [0]; for (int i = 0; i < iterations + 1; ++i) { z = z * z + c; if (z.Absolute >= 2f) { returnVal = (float)i / (float)iterations; break; } } }
public static void QuadJulietIterate(int iterations, out float returnVal, params FractalComplexNumber[] complexNos) { returnVal = -1f; FractalComplexNumber z = new FractalComplexNumber(); if (complexNos.Length > 1) { z = complexNos [1]; } FractalComplexNumber c = complexNos [0]; for (int i = 1; i < iterations + 1; ++i) { z = z * z + c; if (z.Absolute >= 2f) { returnVal = (float)i / (float)iterations; break; } } }
public FractalVector2(FractalComplexNumber v) { this.x = v.Real; this.y = v.Imaginary; }
public override bool Equals(object obj) { FractalComplexNumber target = (FractalComplexNumber)obj; return(this.Real == target.Real && this.Imaginary == target.Imaginary); }
public FractalComplexNumber(FractalComplexNumber v) { this.Real = v.Real; this.Imaginary = v.Imaginary; }