Results 1 to 6 of 6

Thread: Sierpinski gasket...

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2003
    Location
    Bombay
    Posts
    7

    Sierpinski gasket...

    I am trying to make a simple pgm to plot sierpinski gasket.. I am using a determistic algo similar to BFS idea which utilises recurssion.... I am taking first 3 mouse ip to get the intial points of the triangle..

    I want to get the new set of inputs on subseqent clicks.. ie 4,5,6th to be next set of data for a fresh gasket.. but the prob i am facing is that since i am using recursion, and since serpinski being a fractal is an infinite loop, it is not coming out of recursion, hence i am unable to gather the next set of ips..

    is there any way out of this, without going in for an iterative counterpart, coz for me recursion is pretty and beautiful...

    appu

  2. #2
    Junior Member Newbie
    Join Date
    Aug 2003
    Location
    Ashford, Middlesex, UK
    Posts
    9

    Re: Sierpinski gasket...

    Sierpinski really isn't a recursive process - it's iterative. You'd probably be better using iteration for this one, and save recursion for a more appropiate task.

    EDIT: Erm, if doing a random plot it's iterative. If you're mathematically generating the whole thing, then it is recursive, yes!

    That said, you could set a limit to the number of levels deep you want it to go, but that doesn't allow the user to interrupt the process, or to let it run indefinitely.

    Maybe you could handle mouse movement and clicks inside the recursive loop, when you receive a click set the position as the first of three points, clear the screen and return. You'll then be back at the mouse input stage waiting for the second two clicks.


    [This message has been edited by cfmdobbie (edited 08-10-2003).]
    Hellomynameis Charlie Dobbie
    Formerly "Charlie (Guest)"

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2003
    Location
    Bombay
    Posts
    7

    Re: Sierpinski gasket...

    actually i am using the non randomised version... have no prob with the former..

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2003
    Location
    Bombay
    Posts
    7

    Re: Sierpinski gasket...

    I wuld like to make my question more generic...

    how does one process mouse and key strokes while inside recurssion...

    is there some threading concepts etc that can be used?

    appu

  5. #5
    Senior Member Regular Contributor nickels's Avatar
    Join Date
    Feb 2000
    Location
    Colorado
    Posts
    284

    Re: Sierpinski gasket...

    I think I see your problem. This is the common problem; how to actually do some processing whilst in a GUI environment. If you just go off and do your processing the whole application freezes up to the user.

    You have one of two choices:
    1) Write your code so it keeps track of where the computations are and periodically release control back to the windowing system. Attach your computation to some idle function.

    If you must use recursion, 1) won't work, so you probably need to:
    2) Write your computation in a separate thread. Post results occasionaly and have the opengl thread process and display the results.

  6. #6
    Member Contributor
    Join Date
    Sep 2002
    Location
    Edmonton Canada
    Posts
    76

    Re: Sierpinski gasket...

    why dont you have a flag set to true when the mouse clicks, then in your recursive algorithm, upon each recursion, you can check this flag.

Similar Threads

  1. drawing dynamic shapes like sierpinski triangle
    By nil3456 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-08-2018, 02:59 PM
  2. Sierpinski pyramid - problem with clearing screen
    By konrad509 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-26-2011, 11:51 AM
  3. colored black and white Sierpinski triangle
    By vulfh in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-10-2003, 11:02 AM
  4. 3D Fractal (Sierpinsky gasket, triangle whatever)
    By Niftybitz in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-26-2002, 06:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean