[Algorithms] Problem with Woo's "Fast Ray-Box Intersection"
Brought to you by:
vexxed72
From: Klaus H. <k_h...@os...> - 2000-08-26 06:30:05
|
Hi all, I have a problem that I don't understand. I have the following line of source in my implementation of Woo's "Fast Ray-Box Intersection": hitpoint[i] = rayOrg[i] + maxT[whichPlane] * rayDir[i]; hitpoint, rayOrg, maxT, and rayDir are all arrays with three floating-point values (indices 0 to 2). Now here are some values: i = 2 (which is a valid index) whichPlane = 0 (also a valid index) rayOrg[i] = -2 maxT[whichPlane] = 2.82843 rayDir[i] = 0.707107 These are all very valid values, and the result should now be: hitpoint[i] = -2 + 2.82843 * 0.707107 = 2.65201e-06 However, the debugger says, that hitpoint[i] = -6.8457097e-008 Okay, so I thought that maybe this is a precision problem. I tried doubles, but I got the same wrong value. Then I thought, that there might be something wrong hitpoint[i], so I replaced that with a local double variable, but the result is still wrong. Why? I cannot believe that 2.65201e-06 is too small to be represented as a double-precision floating-point value. Can someone explain this to me? Or do you see a bug in the above C line? If you don't believe me, then I'm very well willing to upload the code (very small), and you can step through it, and see for yourselves. Niki |