Coding Challenge #14: Fractal Trees – Recursive

Coding Challenge #14: Fractal Trees – Recursive

100 thoughts on “Coding Challenge #14: Fractal Trees – Recursive”

  1. Incredible! For me at least, I’m taking my “second level” programming class, or, whatever you can call it. Ik it must be possible to code these fractal trees in 3D, but can you teach us how? I’m pretty sure it’s not easy, but then maybe? Like, extend Z or something? I’m not sure, I haven’t programmed in 3D just yet.

  2. This is such a great video! I could understand the theory so clearly. I was hoping if you could make the same tutorial for Processing 🙂

  3. recursive for directory crawling. i remember that impressing me like i had discovered intelligent life in space.

  4. Holy shit dude, there needs to be more of you at my university! Thanks so much, I am now addicted to your videos

  5. Why does the first point of every line segment start where the other left off, it is starting at (0, 0) and he only transformed the origin point on the y axis.

  6. I dont know what I did using this python code. It is modified version from two different sources. It very minimal, but it is hard to understand , I tried to track every step using print to the values of "v", "e" and a counter.
    import turtle

    j=turtle.Turtle()
    j.left(90)

    def treec(v, e):
    if v <= 5:
    return
    else:
    j.forward(e)
    treec((3/4)*v-7, e*.8)
    j.left(60)
    treec((6/8)*v-7, e*.5)
    j.right(120)
    treec((6/8)*v-7, e*.5)
    j.left(60)
    j.backward(e)

    treec(70,60)
    I learned that the code should be symetrical reverse, also the turning 120 degrees to do the opposite side. but I coudnt get why it is not finished when the third "treec" is called?

  7. i challenge you to do the 8 queens problem and find all unique solution and display it using recursive something i tried to do but dont understand all about it

  8. That Samsung Ad was hilarious! " 'A double Dongle?', 'yeah, a double dongle'…" "That sounds explicit!". WTF? lol

  9. Read the foot-notes of the code below, this is the gift I had from my experience with mother Ayahuasca:

    function sleep() {

    // Exit condition
    if (lifeIsOver()) {
    return null
    }

    dream()
    wakeUp()
    }

    function wakeUp() {

    // Exit condition
    if (lifeIsOver()) {
    return null
    }

    // Do your thing here
    sleep()
    }

    Nature calls wakeUp() the moment you are born, and until your departure you are kind of stuck in an finite loop of physiological needs which is defined as "being alive".

    Nature is somewhat recursive, infact The Designer of the whole has linked things with their opposite with double-sided tape (the spongy white you can find in any hardware store), so the fact you can sleep implies you can also be awake (but not at the same time), and that happens recursively by one function (sleep) calling its opposite at some point (wakeUp) and viceversa.

    I believe the implication of this are profound (aside from jokes).
    As you may have noticed soul does not belong to the pseudo-code I've written above, that's because soul is the underlying processor of the whole existence itself: it was, it is and it will be, before and after death.

    For the phenomenon describe previously (everything must derive from its opposite) so life must come to death, otherwise nature would prove to be lame (and that's not the case). If it's not truth that living creature have origin from dying ones then everything should return to an inertial state of death.

    I wonder if reality it's a sophisticated computer simulation, where the consciousness is simply passed by reference to an object (instance of the class Body which extends Matter which in turn extends Energy), and we are like boids with that special spark which we call soul.

    Things are getting messy with my reasoning skills but don't lose your faith because it will be clear (once time will lose its weight).
    If you've read all this you should reconsider what you call reality.

  10. Thanks for help, this great energy and inspiration! 😀 I finally made my fractal tree https://codepen.io/Paradoks/pen/yxyqZG

  11. 12:18 if you put that first rotate outside of the if statement you get a different generation with a bunch of circles, did it by mistake but it looks really cool

  12. Hello, this is facinating and i want to learn it BUT i can't download p5.js on windows 10/64. If you can help î'll be a good student 🙂

  13. what is the difference between using "function branch(args) {}" instead of "branch = function(args) {}". I know that the first i can treat as an object so i can instantiate is like "branch = new branch(args)" but otherwise is there really a big difference?

  14. Your videos are so well done really appreciate all of them! was wondering how I would complete this task in processing java cause no push() pop() function that I am aware of?

  15. Can’t you pass an “angle argument” to the branch function and then call it twice in the program – one for right (-angle) and one for left(angle).
    Of course that would result in the program drawing one side of the tree first and then the next side, but that isn’t a disadvantage.

  16. i wrote the entire code and added a bunch of extra math stuff, and then i added something to map with my mouseX and my browser crashed and i lost it…

  17. Lucas Vinícius Galindo Carvalho

    i clicked on a video with Portuguese title, but the video is in english. WHY CANT I DISABLE THE AUTO-TRANSLATE?

  18. Anyone who deal with push and pop functions, would you find it hard to explain me and others, what the functions exactly execute? Not a JS developer.

  19. 9:03 I really want to get good at music sampling and make a remix of all the innocuous funny things you say 😀
    You are such a legend and really good at teaching dude!

  20. yelshAj • 20 years ago

    Me listening to a real-life program teacher – blank mind
    Me listening to The Coding Train – interested

  21. Thanks the POP and PUSH was interesting to see used.
    I added a css style ti make the slide full width but adding this to the setup.
    slider.style('width', `${width}px`);

  22. Does anyone know how 'push' and 'pop' would work in Unreal Engine? I almost have procedural fractal trees working, its working half way. Its recursive to the "right" but not the "left"

  23. So many rules violated … you don't use explicit pops and pushes, recursion does it for you. In order to solve that you add what is missing … put the angle as argument too … Sand now you apply an affine transformation … what fractals actually are …

  24. As a cs student, I can easily say that these videos are better than some of the cs courses given in the university

  25. I am working outside of the P5 program. How would I make an equivalent to the push and pop functions in the Javascript program in Khan Academy?

  26. Sorry if this is kind of a dumb question but how can I have the code run on the chrome browser? I tried making index.html but I cant figure out what to put inside to make the canvas appear. Thanks!

  27. After the first pop() you´ve pushed and poped again, that´s NOT necessary. Take those 2 lines out, and you´ll be okay.
    Awesome channel, congrats!
    (using Processing.py here)

  28. Brendan Roman Music

    Hi Dan, or anyone who can explain this to me: at 5:30 Dan removes
    var len = 100;
    …but the branch() function references the len after the defined variable has been deleted… – and if height – len == the top of the first branch, how does it know what the value of len is?

    Scratching my head on this one. You're a phenomenal teacher and I've already learned so much.

    Thanks!

  29. HIT THE ENTERTAINMENT

    i wanna draw human faces <different> … can someone help me with that…. i wanna create human on web that can talk with us….

Leave a Reply

Your email address will not be published. Required fields are marked *