Chasing the bug round 2
Posted in :
I was pretty stressed out debugging a problem last two weeks. Luckily I saw the light at the end of the tunnel yesterday. I found out the cause: the tolerance of transform matrix. This is a tough problem because it appears to me the problem occurred without any pattern. But later on I realized out of all the randomness, there is something in common: the misplaced components all end up in the same place. I implemented the fix this morning and it worked like a champ.
Tolerance played an important role in my world. I guess it’s just a way of life. The problem is the computer can not represent a number accurately. Say an inch is 25.4 mm, but in computer it is really 25.399999…If you convert the inch to mm and then convert it back, it maybe something like 25.398888. Now if you do a comparason of this number with 25.4, it won’t be equal any more. Similar things can happen for vectors, matrix, geometries, etc.
There are called rounded errors in numerical computation. I took a course on numerical computation in graduate school in Rolla. The theory was a bit abstract. But now I got the fun to play with the real stuff. It’s not as complicated as one might think.