This week I devoted to rotation. To test it I added cubic shape.
I use quaternions to represent orientation of body in space (see Quaternions and spatial rotation).
To integrate orientation of body over time, numerical methods of solving differential equations are used. Currently I use Euler method, but it can be easily replaced by any other, see
Hpysics.ODE. Differential equation itself is produced by
Finally, I added rotation visualization, so if you compile
vis.hs, you can watch falling rotating cube.
Next, I need to handle collisions properly with respect to rotation. So, I'll need to implement collision detection for cubic shape, and when bodies collide, angular momentum should be added in addition to linear.
I also think about documentation, which should be added at some point. On the one hand, haddock is convenient with its hyperlinks. On the other, literate haskell is interesting alternative. It can be less formal and more descriptive then haddock.