Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I use a kd-tree? [closed]

The other day, I was reading about kd-trees. I was looking for a concrete and simple situation where such a data structure could be useful. Does anybody have such an example?

like image 821
Jean-Pascal Billaud Avatar asked Feb 28 '12 19:02

Jean-Pascal Billaud


1 Answers

I used a kd-tree to simulate light transport through spray generated by a wave. This made it possible to render droplets of spray that weren't just illuminated by lamps, but also indirect lighting coming from other droplets.

I stored points of spray in a kd-tree and then used the kd-tree to quickly find which points were near each other, and hence which droplets of water were illuminated by each other. (Actually, it was a little more sophisticated, but the structure was still a kd-tree.) This made it possible to render a nice glow through the spray.

Here's a picture of the method in use.

Simulated light transport

Note how the spray around the lights is glowing with scattered light.

like image 194
sigfpe Avatar answered Oct 04 '22 07:10

sigfpe