Press escape to exit fullscreen

{{sketch.instructions}}

CC {{sketch.licenseObject.short}}

Archived Sketch

This sketch is created with an older version of Processing,
and doesn't work on browsers anymore.

View Source Code

Capture Screenshot

Particle Simulation with KD Tree

{{$t('general.by')}}
Click and drag to interact with the particles. I've used a KD Tree algorithm to search for the nearest neighbour for each particle. This reduces the number of collision detections per frame down to 1 per particle. The KD-Tree algorithm has come from: http://thomasdiewald.com/blog/?p=1689. There is an old open processing sketch, which doesn't work with processing.js, here: http://www.openprocessing.org/sketch/92253 Working from the Processing.org 2.0 example 'CircleCollision' by Ira Greenberg, based on Keith Peter's solution in Foundation Actionscript Animation: Making Things Move!
We recovered an unsaved version of this sketch. Please review your changes below.

As a Plus+ Member feature, this source code is hidden by the owner.

  • {{co.title}}
    {{$t('sketch.mode-pjs')}} {{$t('general.learnMore')}}
    Select mode or a template
    {{liveCodeLink}}
    • {{l.url.substr(l.url.lastIndexOf('/') + 1)}}
    {{$t('sketch.layoutDescription')}}

    {{k.category}}
    {{k.label}}
    {{k.description}}

    {{$t('sketch.seeMoreShortcuts')}}

    Versions are only kept for 7 days.
    Join Plus+ to keep versions indefinitely!

    {{$t('general.joinPlus')}}


    {{$t('sketch.versionsSummarized')}}