main page

My reading list

From 1995 on i kept a list of all the novels i read. Sometime around 2004 i put them all into my then brandnew mySQL database and continued the list with more specific data about each book: the first sentence, the publishing year and the date i started reading it. I used the data on my website before, displaying only the first sentence of what's on my bookshelf right now with the help of a simple php-script.

Now i wanted to create a visualization that allows to browse my reading list and look at it from different angles, by including the publishing date and my own reading date as search parameter. That the books ended up as spheres in an abstract physics simulation was not intended. I guess at some point during developing it, i got so hooked on creating realistic bouncing behaviors that the original function of displaying data got pushed into the background. So now you can look at the result in two ways: an abstract way of observing my reading behavior and a toy for playing with spheres in a 3d world.

First Sentences

I love books. And i love first sentences. Sometimes the first sentence reveals a lot of the story to come. It can set the tone for the rest of the book. Since i started the database, i got into the habit of pausing after reading the first sentence whenever i start a new book. Simply to admire them.

Here a selection, some new, some old, some simply famous:

The Setup

3d spheres, displayed as 2d circles for rendering benefits, are placed in a a 3d space confined by invisible walls. The spheres either follow an attraction to the center of the space, or downward gravity. The move around the space according to the usual velocity/acceleration calculations.

The first implementation on the left shows the spheres bouncing off the outer walls, yet not each other. A simple collision detection avoids them inhabiting the same space at. So instead of bouncing off each other they simple keep pushing into each other.

Strange Rotations

Some experiments later i discovered that if a large number of spheres are attracted to the center, they would start to follow a strange rotation pattern. You can see the effect on the video on the right above. Playing around with pseudo-physics gets interesting when strange behaviors emerge from coding mistakes. Which can be good and bad, depending on where you want to take the whole piece. For my part, i spend way too much time trying to locate the problem, and didn't even find it in the end. I guessed it would be somewhere in the collision detection, so i decided to implement a more proper solution that allows the spheres to bounce off each other.


Figuring out the correct formulas for how 2 spheres bounce off each other, took me a while and a lot of searching through forums. Basically the spheres swap those parts of their current velocities that go parallel to the distance normal between the two spheres. If a moving sphere hits a static one, the moving sphere will stop while the other one bounces off. (Remember that toy … ) The spheres keep the perpendicular components of their initial velocity. The whole thing is of course affected by their masses. The heavier the sphere, the more force is acting upon the other sphere. The whole result is then multiplied with an elasticity parameter, that should be giving according to material properties. A value of 0 means, no bouncing action at all, while a value of 1 gives perfect frictionless bouncing.

This rendering was done with the P5Sunflow ray tracing library.