Clutter Engine 0.0.1
Loading...
Searching...
No Matches
fast_square_root.inl
1
2
3namespace glm
4{
5 // fastSqrt
6 template<typename genType>
7 GLM_FUNC_QUALIFIER genType fastSqrt(genType x)
8 {
9 GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fastSqrt' only accept floating-point input");
10
11 return genType(1) / fastInverseSqrt(x);
12 }
13
14 template<length_t L, typename T, qualifier Q>
15 GLM_FUNC_QUALIFIER vec<L, T, Q> fastSqrt(vec<L, T, Q> const& x)
16 {
18 }
19
20 // fastInversesqrt
21 template<typename genType>
26
27 template<length_t L, typename T, qualifier Q>
32
33 // fastLength
34 template<typename genType>
35 GLM_FUNC_QUALIFIER genType fastLength(genType x)
36 {
37 GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fastLength' only accept floating-point inputs");
38
39 return abs(x);
40 }
41
42 template<length_t L, typename T, qualifier Q>
43 GLM_FUNC_QUALIFIER T fastLength(vec<L, T, Q> const& x)
44 {
45 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'fastLength' only accept floating-point inputs");
46
47 return fastSqrt(dot(x, x));
48 }
49
50 // fastDistance
51 template<typename genType>
52 GLM_FUNC_QUALIFIER genType fastDistance(genType x, genType y)
53 {
54 return fastLength(y - x);
55 }
56
57 template<length_t L, typename T, qualifier Q>
58 GLM_FUNC_QUALIFIER T fastDistance(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
59 {
60 return fastLength(y - x);
61 }
62
63 // fastNormalize
64 template<typename genType>
65 GLM_FUNC_QUALIFIER genType fastNormalize(genType x)
66 {
67 return x > genType(0) ? genType(1) : -genType(1);
68 }
69
70 template<length_t L, typename T, qualifier Q>
71 GLM_FUNC_QUALIFIER vec<L, T, Q> fastNormalize(vec<L, T, Q> const& x)
72 {
73 return x * fastInverseSqrt(dot(x, x));
74 }
75}//namespace glm
GLM_FUNC_DECL GLM_CONSTEXPR genType abs(genType x)
GLM_FUNC_DECL genType fastNormalize(genType const &x)
GLM_FUNC_DECL genType fastSqrt(genType x)
Definition fast_square_root.inl:7
GLM_FUNC_DECL genType fastInverseSqrt(genType x)
Definition fast_square_root.inl:22
GLM_FUNC_DECL genType fastDistance(genType x, genType y)
Definition fast_square_root.inl:52
GLM_FUNC_DECL genType fastLength(genType x)
Definition fast_square_root.inl:35
Core features
Definition common.hpp:21
Definition func_exponential.inl:45
Definition _vectorize.hpp:7
Definition qualifier.hpp:35