DarkRadiant: master cda42e96
Author | Committer | Branch | Timestamp | Parent |
---|---|---|---|---|
orbweaver | orbweaver | master | 04.04.2021 13:47 | master 57622537 |
Changeset | Fix inaccuracy in Vector3 getLength()/getLengthSquared() Although our Vector3 is double precision, for some reason getLength() and getLengthSquared() were forcing everything to float precision. getLengthSquared() now operates in the native T type (this will work even for a hypothetical BasicVector3<int>, since it's just multiplication and addition), and is implemented as the dot product of the vector with itself for simplicity. getLength() now returns double, since std::sqrt() always returns a double anyway so there is no point in converting it at this point. This allows the VectorLength unit test to compare for exact equality rather than using an epsilon (the same calculation on the same compiler with the same FPU should give consistent results). |
|||
mod - libs/math/Vector3.h | Diff File | |||
mod - test/math/Vector.cpp | Diff File |