From 7d20bc8104771046a87858d106b8bde3573f8727 Mon Sep 17 00:00:00 2001 From: Liam Adams Date: Fri, 19 Jul 2019 17:53:19 +0100 Subject: [PATCH] Take the absolute vaue of the components to avoid possible negative norm values. --- glm/gtx/norm.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glm/gtx/norm.inl b/glm/gtx/norm.inl index c3f468c3..aec92bc2 100644 --- a/glm/gtx/norm.inl +++ b/glm/gtx/norm.inl @@ -71,13 +71,13 @@ namespace detail template GLM_FUNC_QUALIFIER T lxNorm(vec<3, T, Q> const& x, vec<3, T, Q> const& y, unsigned int Depth) { - return pow(pow(y.x - x.x, T(Depth)) + pow(y.y - x.y, T(Depth)) + pow(y.z - x.z, T(Depth)), T(1) / T(Depth)); + return pow(pow(abs(y.x - x.x), T(Depth)) + pow(abs(y.y - x.y), T(Depth)) + pow(abs(y.z - x.z), T(Depth)), T(1) / T(Depth)); } template GLM_FUNC_QUALIFIER T lxNorm(vec<3, T, Q> const& v, unsigned int Depth) { - return pow(pow(v.x, T(Depth)) + pow(v.y, T(Depth)) + pow(v.z, T(Depth)), T(1) / T(Depth)); + return pow(pow(abs(v.x), T(Depth)) + pow(abs(v.y), T(Depth)) + pow(abs(v.z), T(Depth)), T(1) / T(Depth)); } }//namespace glm