Thread: Stuck

  1. #1
    * S T U D E N T *
    Join Date
    Oct 2003

    Unhappy Stuck

    Hey people.
    Trying to draw a mandlebrot set as a part of a lab session.
    Here is my code for mandelbrot.c so far...
    #include <stdio.h>
    #include <mbrot.h>
    int main()
      double mandX, mandY;
      int test;
      Colour colour;
      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);
        /* do nothing and wait for termination in console*/
    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));
        if (iterations == 200 && mod_z2 < 4)
          iterations = 0.0;
      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....


  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    mandX = 2;
    mandY = 1;

    mandX = i;
    mandY = j;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 10-23-2006, 07:22 PM
  2. string array stuck:(
    By mass in forum C Programming
    Replies: 18
    Last Post: 05-22-2006, 04:44 PM
  3. Program stuck in infinite loop-->PLEASE HELP
    By Jedijacob in forum C Programming
    Replies: 5
    Last Post: 03-26-2005, 12:40 PM
  4. Stuck on random generating
    By Vegtro in forum C++ Programming
    Replies: 3
    Last Post: 10-01-2003, 07:37 PM
  5. stuck ky
    By JaWiB in forum Tech Board
    Replies: 2
    Last Post: 06-15-2003, 08:28 PM