Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Building fractal tree with recursion

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Building fractal tree with recursion

    Hey guys,

    i have the following question: I want to use StdDraw Library to draw a fractal tree using recursion like this:

    fractal_tree.png.png

    I think you understand the idea. But I need a hint, how I can grow the child-cubes recursively. My first idea : I calculate the left-top point of each cube and draw a new one. If the side-length lesser than e.g. 1, i return and to the right cube, doing the same. But then I have to recalculate the point to find the next branch - it's possible, but I'm afraid that's not the point of the exercise, because i have to do this 10000 times until the tree is done.

    I understand the trigonometric calculations, i'm also able to build two branches recursively.... but how can I develop an algorithm who "knows" where the next branch starts? And knows that the cubes borns exponential??

    Would be glad if somebody could give me a hint!

    Best regards!

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Building fractal tree with recursion

    Moved out of java coding section
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Fractal Triangle, Recursion to make children triangles
    By devingero95 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 8th, 2014, 07:12 PM
  2. Building game tree
    By IHeartProgramming in forum Java Theory & Questions
    Replies: 1
    Last Post: December 6th, 2012, 09:54 AM
  3. binary tree not building correctly
    By NCNerdGirl in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 21st, 2012, 12:24 PM
  4. Building a binary search tree
    By Herah in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 28th, 2011, 07:29 AM