Skip to main content

Simple Particle Simulation (KD-Tree)

I modified the 2.0 example CircleCollision to include some mouse interaction and friction.  The code is up on

Edit: I've now tweaked it to include a KD-Tree data structure, This reduces the number of collision detections per frame down to 1 per particle.  It is computationally cheaper to build the KD-Tree on each iteration than it is to check every particle against every other particle.  The KD-Tree algorithm has been modified from an example by Thomas Diewald.

Edit: I've now tweaked it to include Probabilistic collision detection.

You can interact with this one :)

Popular posts from this blog

DIY Planar Magnetic drivers, part 1

I've been putting together some planar magnetic loud speaker drivers.  There is a wealth of information available at, particularly in this thread.   Inner Fidelity have a nice write up on planar magnetic drivers.  Euwemax documents his DIY planar magnetic drivers for headphones, and he uses etching as his principle method.  I thought I'd attempt to build some using enamelled wire and embroidery hoops.  This post documents my progress so far.  I've made working prototypes, but at the moment the sound is clipping.

Arduino, Smooth RC Servo Motor Control

When using the arduino Servo.h library, you normally use myServo.write(), but you can use myServo.writeMicroseconds().  This lets you write out the controlling squarewave period in microseconds.  The rc servo standard is typically 1000us <-> 2000us, with 1500us as neutral position.  This means that you have a resolution of ~2000 individual steps, rather than the 180 (degree) steps the normal write() would provide - and therefore, the potential for significantly smoother servo motor movements. 

Check out:

Here is the test code I have used to good effect so far, I have been using servo motors with an extended range of uSeconds.  Currently using one pot to set the target position, and the second pot to change the ramping/smoothing fraction.  Ramping/smoothing is done with a technique called easing (see here) which means continually adding a fraction-of-the-difference between target and current position.  See below, very simple…

DS1307 woes, I2C freezes and locks arduino

I've come across a problem with the DS1307 real time clock module and I thought I'd share my work around solution.