The particles are attracted by the position of the mouse, each having a slightly different (randomized) attraction factor.
If a particle ever reaches the exact mouse coordinates, its position is randomly generated anywhere on the screen.
When rendering the particles, it simply draws a line between the previous and the new position. So when a particle is transported to a random place, it create the rays that appear around the cursor.
There's no real complexity in the maths involved, but I remember spending quite some time tweaking the random ranges to get something nice.
Have you seen this VR demo: http://youtu.be/fAhzW4blqvM ? It looks similar enough that I bet it's inspired by yours.
Yours is a very fun demo. I tried modifying it to move more work to the GPU. I had the CPU only update a subset of the particles each frame and the GPU would interpolate a curve to fill in the missing frame updates. It sorta worked. It was N-times faster and could do more particles. But, the interpolated curves were progressively less responsive and fun.
If a particle ever reaches the exact mouse coordinates, its position is randomly generated anywhere on the screen.
When rendering the particles, it simply draws a line between the previous and the new position. So when a particle is transported to a random place, it create the rays that appear around the cursor.
There's no real complexity in the maths involved, but I remember spending quite some time tweaking the random ranges to get something nice.