Saturday, June 28, 2008

Status report: week 5

This week I was implementing Mirtich's V-Clip algorithm for collision detection.

Also I found several bugs in my functions, which took some time to fix. To check the code I used QuickCheck properties. I expect to finish V-Clip during the first half of the following week, if everthing goes fine.

I also found time to cabalize and haddockize Hpysics. Note that you need haddock 2 to build docs, because earlier versions don't like parallel arrays syntax.

Also, there was an interesting challenge with QuickCheck. To test some things I need to generate non-zero vectors. I tried the following:

nonzero :: Gen Vec
nonzero = do
  v <- arbitrary
  if norm v > 0 then return v else nonzero

(i.e. if we got zero vector, just generate another one until we get what we want), but for some reason this code doesn't terminate. To understand why, I probably should learn more about how QuickCheck's rng works, but I won't complain if someone explains this effect :)

No comments: