Clutter Engine 0.0.1
Loading...
Searching...
No Matches
norm.inl
1
2
3#include "../detail/qualifier.hpp"
4
5namespace glm{
6namespace detail
7{
8 template<length_t L, typename T, qualifier Q, bool Aligned>
10 {
11 GLM_FUNC_QUALIFIER static T call(vec<L, T, Q> const& v)
12 {
13 return dot(v, v);
14 }
15 };
16}//namespace detail
17
18 template<typename genType>
19 GLM_FUNC_QUALIFIER genType length2(genType x)
20 {
21 GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'length2' accepts only floating-point inputs");
22 return x * x;
23 }
24
25 template<length_t L, typename T, qualifier Q>
26 GLM_FUNC_QUALIFIER T length2(vec<L, T, Q> const& v)
27 {
28 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'length2' accepts only floating-point inputs");
30 }
31
32 template<typename T>
33 GLM_FUNC_QUALIFIER T distance2(T p0, T p1)
34 {
35 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'distance2' accepts only floating-point inputs");
36 return length2(p1 - p0);
37 }
38
39 template<length_t L, typename T, qualifier Q>
40 GLM_FUNC_QUALIFIER T distance2(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1)
41 {
42 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'distance2' accepts only floating-point inputs");
43 return length2(p1 - p0);
44 }
45
46 template<typename T, qualifier Q>
47 GLM_FUNC_QUALIFIER T l1Norm(vec<3, T, Q> const& a, vec<3, T, Q> const& b)
48 {
49 return abs(b.x - a.x) + abs(b.y - a.y) + abs(b.z - a.z);
50 }
51
52 template<typename T, qualifier Q>
53 GLM_FUNC_QUALIFIER T l1Norm(vec<3, T, Q> const& v)
54 {
55 return abs(v.x) + abs(v.y) + abs(v.z);
56 }
57
58 template<typename T, qualifier Q>
59 GLM_FUNC_QUALIFIER T l2Norm(vec<3, T, Q> const& a, vec<3, T, Q> const& b
60 )
61 {
62 return length(b - a);
63 }
64
65 template<typename T, qualifier Q>
66 GLM_FUNC_QUALIFIER T l2Norm(vec<3, T, Q> const& v)
67 {
68 return length(v);
69 }
70
71 template<typename T, qualifier Q>
72 GLM_FUNC_QUALIFIER T lxNorm(vec<3, T, Q> const& x, vec<3, T, Q> const& y, unsigned int Depth)
73 {
74 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));
75 }
76
77 template<typename T, qualifier Q>
78 GLM_FUNC_QUALIFIER T lxNorm(vec<3, T, Q> const& v, unsigned int Depth)
79 {
80 return pow(pow(abs(v.x), T(Depth)) + pow(abs(v.y), T(Depth)) + pow(abs(v.z), T(Depth)), T(1) / T(Depth));
81 }
82
83 template<typename T, qualifier Q>
84 GLM_FUNC_QUALIFIER T lMaxNorm(vec<3, T, Q> const& a, vec<3, T, Q> const& b)
85 {
86 return compMax(abs(b - a));
87 }
88
89 template<typename T, qualifier Q>
90 GLM_FUNC_QUALIFIER T lMaxNorm(vec<3, T, Q> const& v)
91 {
92 return compMax(abs(v));
93 }
94
95}//namespace glm
GLM_FUNC_DECL GLM_CONSTEXPR genType abs(genType x)
GLM_FUNC_QUALIFIER vec< L, T, Q > pow(vec< L, T, Q > const &base, vec< L, T, Q > const &exponent)
Definition func_exponential.inl:72
GLM_FUNC_DECL genType::value_type compMax(genType const &v)
GLM_FUNC_DECL T l2Norm(vec< 3, T, Q > const &x, vec< 3, T, Q > const &y)
Definition norm.inl:59
GLM_FUNC_DECL T distance2(vec< L, T, Q > const &p0, vec< L, T, Q > const &p1)
Definition norm.inl:40
GLM_FUNC_DECL T length2(vec< L, T, Q > const &x)
Definition norm.inl:26
GLM_FUNC_DECL T lxNorm(vec< 3, T, Q > const &x, vec< 3, T, Q > const &y, unsigned int Depth)
Definition norm.inl:72
GLM_FUNC_DECL T lMaxNorm(vec< 3, T, Q > const &x, vec< 3, T, Q > const &y)
Definition norm.inl:84
GLM_FUNC_DECL T l1Norm(vec< 3, T, Q > const &x, vec< 3, T, Q > const &y)
Definition norm.inl:47
detail namespace with internal helper functions
Definition json.h:249
Core features
Definition common.hpp:21
Definition norm.inl:10
Definition qualifier.hpp:35