Is there a way to check for overflow of doubles in java? I'm working on a Raytracing application and I'm getting some anomolies with portions of infinite planes showing up where they shouldn't be. I've deduced that this is because the z value of the intersection of a ray and the plane x = constant, for instance, overflows for some rays. This causes the intersection distance to be less than it actually is, so the color of that plane shows up instead of the color of a different (correct) object.
So I'd like to detect overflow and throw away that intersection value if possible. Any ideas?
Here's a pic, so you see what I mean.
The Green plane is z = 300.0
The Blue plane is y = -50.0
So they should meet at a horizontal line and the green one should go all the way to the top, but the blue one interferes.
Image
I can post code if you want, but I really think it's just the overflow thing that's the problem.




Reply With Quote