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 Hpysics.Simulation.rotationDE.
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.

7 comments:
If you put Make file, it would be easy to compile vis.hs.
It is as easy as typing "ghc --make vis".
Also you'll need to install additional libraries (OpenGL+GLUT Haskell bindings and maybe GHC.PArr if it isn't shipped with your GHC distribution).
I'll cabalize it, but a bit later...
Please use Haddock and not literate Haskell. The GHC source code is a good example of how the literate style just doesn't work in a typical open source project.
Interesting. I haven't looked at GHC source yet; what's wrong with it?
I compiled it but discover that I haven't glx support in Xserver. OMG:)
alogic: me too. I think it can be enabled somehow...
Anyway, vis should work (although with some performance problems).
Post a Comment