public override int GetNextPixel(int coordX, int coordY) { double xValue = this.XStartValue + this.xOffset * coordX; double yValue = this.YStartValue + this.yOffset * coordY; ComplexPoint z = new ComplexPoint(xValue, yValue); ComplexPoint z1 = new ComplexPoint(1, 0); int it = 0; double tolerance = 0.000000001; if (Math.Abs(xValue) > tolerance || Math.Abs(yValue) > tolerance) { while (it < iterations && z1.GetModulusSquared() > 0.000000001) { Tuple <ComplexPoint, ComplexPoint> strategyResultTuple = this.equationStrategy.CalculateNextPoint(z); z = strategyResultTuple.Item1; z1 = strategyResultTuple.Item2; it++; } } return(it); }
public void Test_complex_point() { var point = new ComplexPoint(0.4, new Complex(0.1, 0.2)); Assert.AreEqual(0.1, point.Y.Real); Assert.AreEqual(0.2, point.Y.Imaginary); Assert.AreEqual(0.4, point.X); }
public Tuple <ComplexPoint, ComplexPoint> CalculateNextPoint(ComplexPoint z) { ComplexPoint z1 = ComplexPoint.Pow(z, 3) - (double)1; ComplexPoint dz = 3 * ComplexPoint.Pow(z, 2); ComplexPoint temp = z1 / dz; z -= temp; return(new Tuple <ComplexPoint, ComplexPoint>(z, z1)); }
public Tuple <ComplexPoint, ComplexPoint> CalculateNextPoint(ComplexPoint z) { ComplexPoint z1 = ComplexPoint.Pow(z, 6) + ComplexPoint.Pow(z, 3) - 1; ComplexPoint dz = 6 * ComplexPoint.Pow(z, 5) + 3 * ComplexPoint.Pow(z, 2); ComplexPoint temp = z1 / dz; z -= temp; return(new Tuple <ComplexPoint, ComplexPoint>(z, z1));; }
/// <summary> /// Calculates the next pixel with the equation Z(n+1) = Z(n)^2 + C /// </summary> public override int GetNextPixel(int coordX, int coordY) { double xValue = this.XStartValue + this.xOffset * coordX; double yValue = this.YStartValue + this.yOffset * coordY; ComplexPoint c = new ComplexPoint(xValue, yValue); ComplexPoint z = new ComplexPoint(0, 0); int it = 0; do { it++; z.Sqrt(); z += c; if (z.GetModulus() > Constants.RangeRadius) { break; } } while (it < this.iterations); return(it); }
public void GET() { //THIS CODE WAS PULLED FROM https://www.codeproject.com/Articles/1177443/Mandelbrot-Set-With-Csharp for (double y = yMin; y < yMax; y += xyStep.y) { int xPix = 0; for (double x = xMin; x < xMax; x += xyStep.x) { ComplexPoint c = new ComplexPoint(x, y); ComplexPoint zk = new ComplexPoint(0, 0); int k = 0; do { zk = zk.doCmplxSqPlusConst(c); modulusSquared = zk.doMoulusSq(); k++; } while ((modulusSquared <= 4.0) && (k < kMax)); if (k < kMax) { if (k == kLast) { color = colorLast; } else { color = colourTable.GetColour(k); colorLast = color; } if (xyPixelStep == 1) { if ((xPix < myBitmap.Width) && (yPix >= 0)) { myBitmap.SetPixel(xPix, yPix, color); } } else { for (int pX = 0; pX < xyPixelStep; pX++) { for (int pY = 0; pY < xyPixelStep; pY++) { if (((xPix + pX) < myBitmap.Width) && ((yPix - pY) >= 0)) { myBitmap.SetPixel(xPix + pX, yPix - pY, color); } } } } } xPix += xyPixelStep; } yPix -= xyPixelStep; } }
public override void SetCustomParameters(int it, string parameters = null) { this.iterations = it; this.complexPoint = ComplexPoint.GetPointFromString(parameters); }