1 #ifndef BLOBS_MATH_GLM_HPP_
2 #define BLOBS_MATH_GLM_HPP_
4 #ifndef GLM_FORCE_RADIANS
5 # define GLM_FORCE_RADIANS 1
10 #include <glm/glm.hpp>
11 #include <glm/gtx/norm.hpp>
12 #include <glm/gtx/component_wise.hpp>
14 // GLM moved tvec[1234] from glm::detail to glm in 0.9.6
19 template<class T, precision P = defaultp>
20 using tvec1 = detail::tvec1<T, P>;
21 template<class T, precision P = defaultp>
22 using tvec2 = detail::tvec2<T, P>;
23 template<class T, precision P = defaultp>
24 using tvec3 = detail::tvec3<T, P>;
25 template<class T, precision P = defaultp>
26 using tvec4 = detail::tvec4<T, P>;
32 inline bool allzero(const T &v) noexcept {
33 return glm::length2(v) <
34 std::numeric_limits<typename T::value_type>::epsilon()
35 * std::numeric_limits<typename T::value_type>::epsilon();
39 inline bool anynan(const T &v) noexcept {
40 return glm::any(glm::isnan(v));
44 inline Vec limit(const Vec &v, typename Vec::value_type max) noexcept {
45 typename Vec::value_type len2 = glm::length2(v);
46 typename Vec::value_type max2 = max * max;
48 return glm::normalize(v) * max;