/// @ref gtx_fast_square_root namespace glm { // fastSqrt template GLM_FUNC_QUALIFIER genType fastSqrt(genType x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fastSqrt' only accept floating-point input"); return genType(1) / fastInverseSqrt(x); } template GLM_FUNC_QUALIFIER vec fastSqrt(vec const& x) { return detail::functor1::call(fastSqrt, x); } // fastInversesqrt template GLM_FUNC_QUALIFIER genType fastInverseSqrt(genType x) { return detail::compute_inversesqrt<1, genType, lowp, detail::is_aligned::value>::call(vec<1, genType, lowp>(x)).x; } template GLM_FUNC_QUALIFIER vec fastInverseSqrt(vec const& x) { return detail::compute_inversesqrt::value>::call(x); } // fastLength template GLM_FUNC_QUALIFIER genType fastLength(genType x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fastLength' only accept floating-point inputs"); return abs(x); } template GLM_FUNC_QUALIFIER T fastLength(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fastLength' only accept floating-point inputs"); return fastSqrt(dot(x, x)); } // fastDistance template GLM_FUNC_QUALIFIER genType fastDistance(genType x, genType y) { return fastLength(y - x); } template GLM_FUNC_QUALIFIER T fastDistance(vec const& x, vec const& y) { return fastLength(y - x); } // fastNormalize template GLM_FUNC_QUALIFIER genType fastNormalize(genType x) { return x > genType(0) ? genType(1) : -genType(1); } template GLM_FUNC_QUALIFIER vec fastNormalize(vec const& x) { return x * fastInverseSqrt(dot(x, x)); } }//namespace glm