Hey people.
Trying to draw a mandlebrot set as a part of a lab session.
Here is my code for mandelbrot.c so far...
Code:
#include <stdio.h>
#include <mbrot.h>
int main()
{
double mandX, mandY;
int test;
Colour colour;
mbrot_makeWindow(MBROT_MAX_SIZE);
int i=0, j=0;
for (i; i<MBROT_MAX_SIZE; i++)
{
for (j; j<MBROT_MAX_SIZE; j++)
{
mandX = 2;
mandY = 1;
test = mSetTest(mandX, mandY);
colour = mbrot_getColour(test);
mbrot_drawPixel(i, j, colour);
}
}
mbrot_update();
while(1)
{
/* do nothing and wait for termination in console*/
}
return(0);
}
int mSetTest(double c_re, double c_im)
{
double new_re = 0.0, new_im = 0.0, mod_z2 = 0.0;
int iterations = 0.0;
while (iterations < 200 && mod_z2 < 4)
{
new_re = ((new_re * new_re) - (new_im * new_im)) + c_re;
new_im = ((2 * new_re * new_im) + c_im);
mod_z2 = ((new_re * new_re) + (new_im * new_im));
iterations++;
if (iterations == 200 && mod_z2 < 4)
{
iterations = 0.0;
break;
}
}
printf("Number of iterations:\t %d\n\n", iterations);
}
basically when it runs i get a blank window and a repeating line saying Number of iterations :1.
I know i have hard coded the values for mandX and mandY but surely something should get drawn?!
does anyone know how to map mandlebrot sets to a pixel map?! coz i am lost COMPLETELY lost and this has to be done by 3 today!
here is some additional info taken for the mbrot.h file...
The library function, mbrot_getColour takes a value from mSetTest and returns a Colour. You can use this function in conjunction with mbrot_drawPixel to colour the whole set.
You have to call mbrot_update in order for the effects to be seen.
plz help me, all help appreciated, thanks....
Chri$