1 #ifndef BLOBS_MATH_GLM_HPP_
2 #define BLOBS_MATH_GLM_HPP_
4 #ifndef GLM_FORCE_RADIANS
5 # define GLM_FORCE_RADIANS 1
8 // wait what? quaternions are experimental -.-
9 #define GLM_ENABLE_EXPERIMENTAL
13 #include <glm/glm.hpp>
14 #include <glm/gtx/norm.hpp>
15 #include <glm/gtx/component_wise.hpp>
17 // GLM moved tvec[1234] from glm::detail to glm in 0.9.6
22 template<class T, precision P = defaultp>
23 using tvec1 = detail::tvec1<T, P>;
24 template<class T, precision P = defaultp>
25 using tvec2 = detail::tvec2<T, P>;
26 template<class T, precision P = defaultp>
27 using tvec3 = detail::tvec3<T, P>;
28 template<class T, precision P = defaultp>
29 using tvec4 = detail::tvec4<T, P>;
35 inline bool allzero(const T &v) noexcept {
36 return glm::length2(v) <
37 std::numeric_limits<typename T::value_type>::epsilon()
38 * std::numeric_limits<typename T::value_type>::epsilon();
42 inline bool anynan(const T &v) noexcept {
43 return glm::any(glm::isnan(v));
47 inline Vec limit(const Vec &v, typename Vec::value_type max) noexcept {
48 typename Vec::value_type len2 = glm::length2(v);
49 typename Vec::value_type max2 = max * max;
51 return glm::normalize(v) * max;