public ComputedFractalValues ReturnComputedFractalValues(RectangleInPlane fractalRectangleIn, int xMaxIn, int yMaxIn, IList <FractalColorValue> fractalColorValuesIn, System.Windows.Forms.ProgressBar fractalProgressIn) { if (fractalColorValuesIn.Count < NumberOfColorUsed) { throw new FractalObserverException("Fractal PythagorasTree needs more colors that are available in the input parameter fractalColorValuesIn!"); } ComputedFractalValues aComputedFractalValuesValues = new ComputedFractalValues(); for (int aCurrentYPos = 0; aCurrentYPos < yMaxIn; aCurrentYPos++) { fractalProgressIn.Value = (int)(100.0 * ((double)aCurrentYPos / (double)yMaxIn)); for (int aCurrentXPos = 0; aCurrentXPos < xMaxIn; aCurrentXPos++) { int tempValue = 0; ComplexNumber c = new ComplexNumber(); c.Re = fractalRectangleIn.StartX + Math.Abs(fractalRectangleIn.StartX - fractalRectangleIn.EndX) * ((double)aCurrentXPos / (double)xMaxIn); c.Im = fractalRectangleIn.StartY + Math.Abs(fractalRectangleIn.StartY - fractalRectangleIn.EndY) * ((double)aCurrentYPos / (double)yMaxIn); int n = 0; myZValues[n].Re = 0.0; myZValues[n].Im = 0.0; // computation of value for function z2+c, if it converges (if it is bounded) the point is part of mandelbrot set do { n++; myZValues[n] = ComplexOperations.Add(Equation.ComplexFunctionValue(myZValues[n - 1]), c); } while (((Math.Abs(myZValues[n].Re) < myMaximumValueForConvergation) && (Math.Abs(myZValues[n].Im) < myMaximumValueForConvergation)) && (n < (MaximumNumberOfIterations - 1))); tempValue = n; ComputedFractalValue aCFValue = new ComputedFractalValue(); FractalColorValue aFractalColorValue = ReturnColor(tempValue, fractalColorValuesIn); aCFValue.ColorValue = aFractalColorValue; aCFValue.AddComputedPoint(new System.Drawing.Point(aCurrentXPos, aCurrentYPos)); aCFValue.TypeOfShape = TypesOfShape.Point; aCFValue.UsedTypeOfCoordinateSystem = TypesOfCoordinateSystem.Screen; aComputedFractalValuesValues.AddComputedFractalValue(aCFValue); } } return(aComputedFractalValuesValues); }
public ComputedFractalValues ReturnComputedFractalValues(RectangleInPlane fractalRectangleIn, int xMaxIn, int yMaxIn, IList <FractalColorValue> fractalColorValuesIn, System.Windows.Forms.ProgressBar fractalProgressIn) { if (fractalColorValuesIn.Count < NumberOfColorUsed) { throw new FractalObserverException("Fractal PythagorasTree needs more colors that are available in the input parameter fractalColorValuesIn!"); } ComputedFractalValues aComputedFractalValues = new ComputedFractalValues(); aComputedFractalValues.ShallFillInterior = false; ComputedFractalValue aCFValue = new ComputedFractalValue(); FractalColorValue aFractalColorValue = ReturnColor(fractalColorValuesIn); aCFValue.ColorValue = aFractalColorValue; aCFValue.TypeOfShape = TypesOfShape.Lines; aCFValue.UsedTypeOfCoordinateSystem = TypesOfCoordinateSystem.Plane; PointInPlane aStartingPoint = new PointInPlane(myFractalArea.MinX, myFractalArea.MaxY); PointInPlane aEndingPoint = new PointInPlane(myFractalArea.MaxX, myFractalArea.MaxY); const int aStartingIteration = 0; const double aAngle = Math.PI / 3.0; // angle of -60 degrees - equilateral triangle PointInPlane tempPointInPlane = RotateLine(aStartingPoint, aEndingPoint, aAngle); CreateNewCurveAndAddItToCFV(aEndingPoint, aStartingPoint, fractalColorValuesIn, ref aCFValue, aStartingIteration); CreateNewCurveAndAddItToCFV(aStartingPoint, tempPointInPlane, fractalColorValuesIn, ref aCFValue, aStartingIteration); CreateNewCurveAndAddItToCFV(tempPointInPlane, aEndingPoint, fractalColorValuesIn, ref aCFValue, aStartingIteration); aComputedFractalValues.AddComputedFractalValue(aCFValue); return(aComputedFractalValues); }
public ComputedFractalValues ReturnComputedFractalValues(RectangleInPlane fractalRectangleIn, int xMaxIn, int yMaxIn, IList <FractalColorValue> fractalColorValuesIn, System.Windows.Forms.ProgressBar fractalProgressIn) { if (fractalColorValuesIn.Count < NumberOfColorUsed) { throw new FractalObserverException("Fractal PythagorasTree needs more colors that are available in the input parameter fractalColorValuesIn!"); } ComputedFractalValues aComputedFractalValues = new ComputedFractalValues(); aComputedFractalValues.ShallFillInterior = false; PointInPlane[] aStartingRectanglePoints = new PointInPlane[4]; aStartingRectanglePoints[0] = new PointInPlane(myFractalArea.MinX, myFractalArea.MaxY); aStartingRectanglePoints[1] = new PointInPlane(myFractalArea.MaxX, myFractalArea.MaxY); aStartingRectanglePoints[2] = new PointInPlane(myFractalArea.MaxX, myFractalArea.MinY); aStartingRectanglePoints[3] = new PointInPlane(myFractalArea.MinX, myFractalArea.MinY); const int aStartingIteration = 0; CreateSquare(aStartingRectanglePoints, fractalColorValuesIn, ref aComputedFractalValues, aStartingIteration); return(aComputedFractalValues); }
public PythagorasTree() { myFractalArea = new RectangleInPlane(-0.5, 0.0, 0.5, 1.0); }
public ComputedFractalValues ReturnComputedFractalValues(RectangleInPlane fractalRectangleIn, int xMaxIn, int yMaxIn, IList <FractalColorValue> fractalColorValuesIn, System.Windows.Forms.ProgressBar fractalProgressIn) { if (fractalColorValuesIn.Count < NumberOfColorUsed) { throw new FractalObserverException("Fractal PythagorasTree needs more colors that are available in the input parameter fractalColorValuesIn!"); } ComputedFractalValues aComputedFractalValues = new ComputedFractalValues(); myZRoots.Clear(); for (int aCurrentYPos = 0; aCurrentYPos < yMaxIn; aCurrentYPos++) { fractalProgressIn.Value = (int)(100.0 * ((double)aCurrentYPos / (double)yMaxIn)); for (int aCurrentXPos = 0; aCurrentXPos < xMaxIn; aCurrentXPos++) { int tempRoot = 0; int tempValue = 0; int n = 0; // initial values myZValues[n].Re = fractalRectangleIn.StartX + Math.Abs(fractalRectangleIn.StartX - fractalRectangleIn.EndX) * ((double)aCurrentXPos / (double)xMaxIn); myZValues[n].Im = fractalRectangleIn.StartY + Math.Abs(fractalRectangleIn.StartY - fractalRectangleIn.EndY) * ((double)aCurrentYPos / (double)yMaxIn); // computation of next values until the maximum iteration count or until the conditions are met do { n++; myZValues[n] = ComplexOperations.Substract(myZValues[n - 1], ComplexOperations.Divide(Equation.ComplexFunctionValue(myZValues[n - 1]), Equation.ComplexFunctionDerivativeValue(myZValues[n - 1]))); } while (((Math.Abs(myZValues[n].Re - myZValues[n - 1].Re) > myTreshold) || (Math.Abs(myZValues[n].Im - myZValues[n - 1].Im) > myTreshold)) && (n < (MaximumNumberOfIterations - 1))); ComputedFractalValue aCFValue = null; FractalColorValue aFractalColorValue; // if the solution did not converge to root, then return zero values if (n >= (MaximumNumberOfIterations - 1) || double.IsNaN(myZValues[n].Re) || double.IsNaN(myZValues[n].Im)) { aCFValue = new ComputedFractalValue(); aFractalColorValue = ReturnColor(tempRoot, tempValue, fractalColorValuesIn); aCFValue.ColorValue = aFractalColorValue; aCFValue.AddComputedPoint(new System.Drawing.Point(aCurrentXPos, aCurrentYPos)); aCFValue.TypeOfShape = TypesOfShape.Point; aCFValue.UsedTypeOfCoordinateSystem = TypesOfCoordinateSystem.Screen; aComputedFractalValues.AddComputedFractalValue(aCFValue); continue; } bool aNewRoot = true; int aRootNumber = 0; // find out if the root is new until now, or if the current root was found already for (int i = 0; i < myZRoots.Count; i++) { if ((Math.Abs(myZRoots[i].Re - myZValues[n].Re) < myTreshold) && (Math.Abs(myZRoots[i].Im - myZValues[n].Im) < myTreshold)) { aNewRoot = false; aRootNumber = i; break; } } // if this root is new until now, add new item to myZRoots List if (aNewRoot) { ComplexNumber aComplexRoot = new ComplexNumber(); aComplexRoot.Re = myZValues[n].Re; aComplexRoot.Im = myZValues[n].Im; myZRoots.Add(aComplexRoot); aRootNumber = myZRoots.Count - 1; } // sets the computed values for this pixel to return structure and return it tempValue = n; if (aRootNumber == 0) { tempRoot = 1; } else if (aRootNumber == 1) { tempRoot = 2; } else if (aRootNumber == 2) { tempRoot = 3; } else { throw new FractalObserverException("Error occured during computation of fractal, wrong number of roots was found!"); } // storing of output of computation aCFValue = new ComputedFractalValue(); aFractalColorValue = ReturnColor(tempRoot, tempValue, fractalColorValuesIn); aCFValue.ColorValue = aFractalColorValue; aCFValue.AddComputedPoint(new System.Drawing.Point(aCurrentXPos, aCurrentYPos)); aCFValue.TypeOfShape = TypesOfShape.Point; aCFValue.UsedTypeOfCoordinateSystem = TypesOfCoordinateSystem.Screen; aComputedFractalValues.AddComputedFractalValue(aCFValue); } } return(aComputedFractalValues); }
public ScreenPlaneCoordinatesTransfornation(int screenWidthIn, int screenHeightIn, RectangleInPlane viewRectangleIn) { ScreenWidth = screenWidthIn; ScreenHeight = screenHeightIn; ViewRectangle = viewRectangleIn; }
public FractalObserverConfiguration() { CurrentRectangle = new RectangleInPlane(); ZoomRectangle = new RectangleInPlane(); PreviousRectangle = new RectangleInPlane(); }
public GridInPlane(RectangleInPlane gridRectangleIn, double xSpacingIn, double ySpacingIn) { GridRectangle = gridRectangleIn; XSpacing = xSpacingIn; YSpacing = ySpacingIn; }
public KochSnowflake() { myFractalArea = new RectangleInPlane(-1.0, 1.0, -1.0, 1.0); }