NaN check implementation in math32.Ray not working
Description:
In order to compare calculation results to NaN, at least the math32.Ray does the following, e.g. in func(*Ray) IntersectPlane(...)
t := ray.DistanceToPlane(plane)
if t == NaN() {
return nil
}
Bug: Comparing NaNs by value does not work. Those NaNs are IEEE 754 NaNs afaik, meaning the exponent bits are all 1 and the mantissa bits are non-zero. So, comparing by value might work (same mantissa) but it would be a rare exception.
You may try math32.NaN() == math32.NaN() if you like, or math.Log(-1.0) == math.Log(-1.0). Playground
Possible solution: NaN-checks in golang can use the math.IsNaN(float64) function. It is possible to extend the math32 by
func IsNaN(subj float32) bool {
return math.IsNaN(float64(subj))
}
This func should be used everywhere a check against NaN has to be performed.
A quick search for == NaN() and == math32.NaN() only returned the code in Ray.IntersectPlane, so maybe this bug does not hurt that much.
Edit: As math32 already has such a IsNaN() function, it only has to be used.