gunship-rs icon indicating copy to clipboard operation
gunship-rs copied to clipboard

Have Vector Normalization Functions Assert On The Zero Vector

Open randomPoison opened this issue 9 years ago • 1 comments

Right now the normalization functions return a zero-length vector if run on the zero vector. This can lead to subtle problems if the code assumes the vector was correctly normalized, so we should instead assert that the incoming vector is not the zero vector.

We should also do the same for Quaternion normalization. It's much less likely to ever get a zero quaternion, but it's worth having the check for correctness (at least in debug builds).

randomPoison avatar Jun 15 '15 21:06 randomPoison

Should we only assert if all coordinates are exactly 0, or should we use an epsilon to check if all members are really close to 0? My vote is for the latter.

randomPoison avatar Sep 17 '16 16:09 randomPoison