vector3 normalize not always correct.


Sometimes the normalize function does not work properly.
I get this error when normalizing a Vector3(0.13243,0,0) (or something.)
I then get a normalized vector of Vector3(0.999999,0,0)...
Closed Jan 26, 2011 at 9:29 PM by vetuomia


vetuomia wrote Jan 26, 2011 at 9:24 PM

This is normal and expected behavior. The error is caused by the finite precision of the floating point numbers, producing a vector with length very close to 1.0 but not exactly. In practice, this rarely matters.

For more information, see [url:http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems] and [url:http://floating-point-gui.de/basic/].

wrote Jan 26, 2011 at 9:29 PM

wrote Jan 26, 2011 at 9:29 PM

wrote Feb 14, 2013 at 8:27 PM

wrote May 16, 2013 at 10:19 AM