CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Posts
    15

    Mandelbrot Set Help needed

    So I have an assignment for a class and need to write a program that will take a defined coordinate plane/grid from user input and check whether each point is in the set. I have already written the code to check whether or not a specific point is in the mandelbrot set.

    What I have to do now (and am having a hard time figuring out) is how to loop through all the possible points so that I can call a method on each one of them.

    Here's an example from possible user input:
    n or Grid = 4; so 4*4 is 16 I know i need to check for 16 points in the center of each of these squares
    xmin = -1.5;
    ymin = -1.0; that is the bottom left corner of the grid
    width = 2.0; so the grid's x plane goes from -1.5 to 0.5 and contains 4 blocks
    height = 2.0; same thing, y goes from -1.0 to 1.0

    So the point in the center of the bottom left block would be (-1.25, -0.75). What i now need to do is check for all 16 of the points in some sort of a loop and store them in variables that can be used for output later on.

    I am calling the following method and passing the following:
    createPoints(n, xmin, ymin, width, height);

    The method definition of createPoints looks like this:
    public static void createPoints(int n, double xmin, double ymin, double width, double height) throws IOException{

    Can anybody possibly help me with how they think the best way of looping through every point would be?

    Thanks very much
    John

  2. #2
    Join Date
    Nov 2003
    Posts
    1,405

    Re: Mandelbrot Set Help needed

    Quote Originally Posted by LBRapid View Post
    Can anybody possibly help me with how they think the best way of looping through every point would be?
    Well at least inroduce Mr. Mandelbrot. What do you want to know?
    Last edited by _uj; January 31st, 2009 at 11:51 PM.

  3. #3
    Join Date
    Sep 2006
    Location
    Eastern, NC, USA
    Posts
    907

    Re: Mandelbrot Set Help needed

    Since you're looping through a 2-dimensional space, I'd use two nested for loops both going from 0 to 4, and using simple math to use each index to calculate the appropriate x and y values.

  4. #4
    Join Date
    Jan 2009
    Posts
    15

    Re: Mandelbrot Set Help needed

    Yeh I was really overthinking a lot of this and then last night before I fell asleep I had a moment where it all made sense. Thanks for your help. I'll let you know if I have other problems with it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured