I have to make a c# program which creates a form and one of its controls has to be a control that makes a sketch of a Mandelbrot set in which you can zoom in and tell on which point you want to centre. In my opinion i'm doing the right thing, but when I want to start the program, I don't get the desired image of a standard Mandelbrot set. For the Mandelbrot sketch control I've got the next bit of my Mandelbrot class:
class Mandelbrotsketchscreen : UserControl
{
//a method that draws every point with a certain paint
//a method that chooses the right colour
//a method that translates the pixel coordinates of the control to the actual coordinates
//gives the number how many times the function has to be used
private static int Mandelnumber(PointF p, PointF middle, double scale, int max, Size size)
{
PointF realpoint = new PointF();
realpoint.X = (float)(middle.X + (p.X - size.Width / 2) * scale);
realpoint.Y = (float)(middle.Y + (p.Y - size.Height / 2) * scale);
PointF help = new PointF(0, 0);
int i;
for (i = 1; i <= max; i++)
{
help.X = help.X * help.X - help.Y * help.Y + realpoint.X;
help.Y = 2 * help.X * help.Y + realpoint.Y;
if (Math.Sqrt(help.X * help.X + help.Y * help.Y) > 2)
break;
}
return i;
}
}
Can someone tell me if I'm doing the calculation wrong or that maybe my loops are wrong?