Coding Challenge #98.3: Quadtree Collisions – Part 3

In part 3 of the Quadtree coding challenge, I apply the algorithm to particle system collisions and test its performance.

🎥 Part 1:
🎥 Part 2:

🔗 Quadtree on Wikipedia:

💻 Quadtree repo:

🚂 The Coding Train website:
💖 Support this channel on Patreon:
To buy Coding Train merchandise:
📚 Book recommendations:


🎥 For an Introduction to Programming:
🎥 For More Coding Challenges:







20 responses to “Coding Challenge #98.3: Quadtree Collisions – Part 3”

  1. Jarv Avatar

    Do you know gpu.js? You can combine it with p5 for really fast renders

  2. MrLollikus Avatar

    Hi Daniel, I am a fairly new viewer but I really enjoy these coding challenges. I code just for fun and my knowledge is limited but you make every coding session really easy to follow and made me start to code more than once. That said, I only really know python and I would like to code similar "graphical" programs but I really don't know how to, do you have some python modules to suggest me? or do you think I should take the opportunity to learn java/js? I would rather avoid that, I don't have a lot of free time with university…
    Thanks again for the great videos!

  3. Max Musterman Avatar

    could you maybe do a video on optic flow?

  4. TrollingAround Avatar

    Ah please make this follow Conways Game of Life rules! *Although cell creation would be tricky!)

  5. Nelman Jay Louie Vasquez Avatar

    Can you make a tetris game using p5.js? :v

  6. EXxT4ZzY Avatar

    You look like The Professor from La Casa de Papel. I like your vids, go on!

  7. Srikanth Velpuri Avatar

    Nice video…Why did you choose p5js over other programming languages like Python, C, C++??

  8. Mike Lezhnin Avatar

    That feeling when you are that guy who made a pull request with the flocking simulation ^^

  9. Erik Avatar

    Use this one weird trick to improve your collision detection by 10x!

  10. Fernando Ferreira Avatar

    I love your videos, you are doing an awesome job!

  11. Rato Caverna Avatar

    I didn't test it but I think doing the check like this will avoid the performance issue too.
    for (i=0;…
    for (j=i+1;…
    if (particle[i].intersect(particle[j]))

  12. kustomweb Avatar

    Bob Ross loves you

  13. Caraxian Avatar

    You should be creating the Point after the particle has moved, not before

  14. Rikkie Gieler Avatar

    You should implement heap sort, merge sort and quicksort

  15. filip krul Avatar

    I don't think that you need to be worried about the points being different sizes. You are checking from point A to point B and later from B to A so if A is smaller than be then it will simply ignore B and when B is checking A will get checked.
    This is because higher * 2 must be higher then lower + higher.

  16. Rage Avatar

    sorry for being late :/ i was learning processing XD.

  17. thanzex Avatar

    I get the range checking, but wouldn't it be better to only check cells of the quadtree adjacent to the one containing the particle in question? A range can contain many subtrees that are not adjacent and thus cannot collide with the particle, would this be less efficient than the range?

  18. Rodrigo René Cura Avatar

    Dude, I think you don't need that second loop, just need to check if points is empty or not. The Circle range is getting only the ones intersecting. If the range has another shape you need to check.

    Now I'm curious about how much the framerate is affected by the second loop.

    Great videos!

Leave a Reply

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