diff --git a/include/common/qvec.hh b/include/common/qvec.hh index 614d69ad..0747a051 100644 --- a/include/common/qvec.hh +++ b/include/common/qvec.hh @@ -420,23 +420,23 @@ template template [[nodiscard]] inline qvec normalize(const qvec &v1, T &len) { - len = length2(v1); - return len ? (v1 * (1.0 / std::sqrt(len))) : v1; + len = length(v1); + return len ? (v1 / len) : v1; } template [[nodiscard]] inline qvec normalize(const qvec &v1) { - T len = length2(v1); - return len ? (v1 * (1.0 / std::sqrt(len))) : v1; + T len = length(v1); + return len ? (v1 / len) : v1; } template inline T normalizeInPlace(qvec &v1) { - T len = length2(v1); + T len = length(v1); if (len) { - v1 *= (1.0 / std::sqrt(len)); + v1 /= len; } return len; }