summaryrefslogtreecommitdiff
path: root/src/glm/gtx/norm.hpp
blob: af0d6303ea27bdb378c3c4d1c6129e7ecb4ef965 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2005-12-21
// Updated : 2008-07-24
// Licence : This source is under MIT License
// File    : glm/gtx/norm.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
// - GLM_GTX_quaternion
///////////////////////////////////////////////////////////////////////////////////////////////////
// ToDo:
// - Study the validity of the notion of length2 to quaternion
///////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef glm_gtx_norm
#define glm_gtx_norm

// Dependency:
#include "../glm.hpp"
#include "../gtx/quaternion.hpp"

#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#	pragma message("GLM: GLM_GTX_norm extension included")
#endif

namespace glm{
namespace gtx{
namespace norm ///< GLM_GTX_norm extension: Various way to compute vector norms.
{
	/// \addtogroup gtx_norm
	/// @{

	//! Returns the squared length of x.
	//! From GLM_GTX_norm extension.
	template <typename T> 
	T length2(
		const T x);

	//! Returns the squared length of x.
	//! From GLM_GTX_norm extension.
	template <typename T> 
	T length2(
		const detail::tvec2<T> & x);

	//! Returns the squared length of x.
	//! From GLM_GTX_norm extension.
	template <typename T>
	T length2(
		const detail::tvec3<T>& x);
		
	//! Returns the squared length of x.
	//! From GLM_GTX_norm extension.
	template <typename T> 
	T length2(
		const detail::tvec4<T>& x);
		
	//! Returns the squared length of x.
	//! From GLM_GTX_norm extension.
	template <typename T>
	T length2(
		const detail::tquat<T>& q);

	//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
	//! From GLM_GTX_norm extension.
	template <typename T>
	T distance2(
		const T p0, 
		const T p1);
		
	//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
	//! From GLM_GTX_norm extension.
	template <typename T> 
	T distance2(
		const detail::tvec2<T>& p0, 
		const detail::tvec2<T>& p1);

	//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
	//! From GLM_GTX_norm extension.
	template <typename T>
	T distance2(
		const detail::tvec3<T>& p0,
		const detail::tvec3<T>& p1);

	//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
	//! From GLM_GTX_norm extension.
	template <typename T>
	T distance2(
		const detail::tvec4<T>& p0, 
		const detail::tvec4<T>& p1);

	//! Returns the L1 norm between x and y.
	//! From GLM_GTX_norm extension.
	template <typename T>
	T l1Norm(
		const detail::tvec3<T>& x,
		const detail::tvec3<T>& y);
		
	//! Returns the L1 norm of v.
	//! From GLM_GTX_norm extension.
	template <typename T> 
	T l1Norm(
		const detail::tvec3<T>& v);
		
	//! Returns the L2 norm between x and y.
	//! From GLM_GTX_norm extension.
	template <typename T> 
	T l2Norm(
		const detail::tvec3<T>& x, 
		const detail::tvec3<T>& y);
		
	//! Returns the L2 norm of v.
	//! From GLM_GTX_norm extension.
	template <typename T> 
	T l2Norm(
		const detail::tvec3<T>& x);
		
	//! Returns the L norm between x and y.
	//! From GLM_GTX_norm extension.
	template <typename T> 
	T lxNorm(
		const detail::tvec3<T>& x,
		const detail::tvec3<T>& y,
		unsigned int Depth);

	//! Returns the L norm of v.
	//! From GLM_GTX_norm extension.
	template <typename T>
	T lxNorm(
		const detail::tvec3<T>& x,
		unsigned int Depth);

	/// @}
}//namespace norm
}//namespace gtx
}//namespace glm

#include "norm.inl"

namespace glm{using namespace gtx::norm;}

#endif//glm_gtx_norm