Page 1 of 1

[fixed] vector3d's normalize() doesn't handle null vector

Posted: Fri Apr 17, 2009 9:09 am
by Piraaate
Hi guys,
Well everything is pretty much in the title, I'm currently upgrading from my 1.4 version to the latest svn version and I searched for an entire day to discover this "bug".
The comment above the normalize() method is quite clear : "In case of the 0 vector the result is still 0" and now we get a -1.#IND000...

Bug tracker entry
(in my opinion it's a bug that needs a very quick fix)

Posted: Mon Apr 20, 2009 5:39 pm
by CuteAlien
I guess returning NAN and returning 0 would both be correct. I'm not even sure what I would prefer here, probably 0 because that wouldn't change the old behaviour (otherwise I would prefer NAN). I just googled a little around and found some discussion on stackoverflow about this: http://stackoverflow.com/questions/7220 ... ero-vector

In any case code certainly should do as the documentation says - so one of both has to be changed.

Posted: Mon Apr 20, 2009 7:50 pm
by Dark_Kilauea
I think it should just do a simple check to see if the vector is zero and pass through the vector as is if the condition is true.