## Tuesday, August 12, 2008

### Status report: week 11-12

As I wrote before, I added complete support for polyhedra and fixed collision handler.

Also, I made a little optimization to collision detector: bounding spheres. The idea is that testing spheres for collision is faster than testing polyhedra. Also, if we consider sphere with center in body's center of mass, it's rotationally invariant.

Then I spent some time trying to compile head GHC and DPH. My (not so pleasant) experience is described here.

When I succeeded, I wrote simple benchmark to evaluate gains from using bounding volumes. Result was disappointing -- simple 2-step simulation with 10 bodies took 9 seconds and almost 1Gb of memory to complete. After consulting with my mentors we concluded that vectoriser is not ready yet (delay is due to issues with GHC build system) and that I should postpone benchmarks for a while.

So, my plans for nearest future is to implement static bodies and BSP trees (I already started the latter). Until 21 of August I will be teaching at summer math. school, and then I will continue the work.

Also, I'll be writing SoC report for the Monad Reader soon. If you'd like some particular issue to be explained or highlighted there, feel free to tell me!

## Wednesday, August 6, 2008

### Physics and polyhedra

Thanks to my fellow physicist, Oleg Matveychuk, I've done with the collision handler bug I said in the last status report. That was indeed a mistake in the paper (Collision Detection and Response for Computer Animation).

One of the collision equation in that paper looks like

$(v_2+\omega_2\times\rho_2-v_1-\omega_1\times\rho_1)\cdot k=0.$

Here, $v_i$ is linear and $\omega_i$ is angular velocity of each of two bodies, $\rho_i$ is the vector pointing from center of mass to collision point, and $k$ is normal to collision plane. The expression in parens, let's call it $V$, is relative velocity of collision points of two bodies. So, Moore and Wilhelms propose to set $V$ to 0.

It appears that this corresponds to completely unelastic collision (with restitution coefficient equal to 0), and that's why it doesn't look too realistic.

If we have coefficient of restitution $\alpha$, then proper equation is $V'=\alpha V$, where $V'$ is taken after collision and $V$ before.

Another thing I've done is support of generic polyhedra. For example, now we can experiment not just with cubes, but with parallelepipeds or tetrahedra. And in future this will help us to handle arbitrary shapes by approximating them with polyhedra, using point repulsion algorithm which I'm going to implement (it's also needed for semi-adjusting BSP trees).

## Saturday, August 2, 2008

### Status report: week 9-10

I'm back from IMC at Bulgaria with second prize, and ready to work!

While I was away I thought about generic convex polyhedra and actually started implementing them. I hope to finish that in a few days. This not only makes engine practically more useful but also makes some computations more cheap and robust.

Also I discovered some problem with my last collision handler. It conforms to one paper, and now I doubt that paper is correct. I'll consult local physicists in the nearest time.

Finally, I read several papers on broad-phase collision detection. The one I liked most is Broad-Phase Collision Detection Using Semi-Adjusting BSP-trees. So I'll start implementing it as soon as possible.