• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/// @ref gtx_matrix_query
2/// @file glm/gtx/matrix_query.inl
3
4namespace glm
5{
6	template<typename T, precision P>
7	GLM_FUNC_QUALIFIER bool isNull(tmat2x2<T, P> const & m, T const & epsilon)
8	{
9		bool result = true;
10		for(length_t i = 0; result && i < m.length() ; ++i)
11			result = isNull(m[i], epsilon);
12		return result;
13	}
14
15	template<typename T, precision P>
16	GLM_FUNC_QUALIFIER bool isNull(tmat3x3<T, P> const & m, T const & epsilon)
17	{
18		bool result = true;
19		for(length_t i = 0; result && i < m.length() ; ++i)
20			result = isNull(m[i], epsilon);
21		return result;
22	}
23
24	template<typename T, precision P>
25	GLM_FUNC_QUALIFIER bool isNull(tmat4x4<T, P> const & m, T const & epsilon)
26	{
27		bool result = true;
28		for(length_t i = 0; result && i < m.length() ; ++i)
29			result = isNull(m[i], epsilon);
30		return result;
31	}
32
33	template<typename T, precision P, template <typename, precision> class matType>
34	GLM_FUNC_QUALIFIER bool isIdentity(matType<T, P> const & m, T const & epsilon)
35	{
36		bool result = true;
37		for(length_t i = 0; result && i < m[0].length() ; ++i)
38		{
39			for(length_t j = 0; result && j < i ; ++j)
40				result = abs(m[i][j]) <= epsilon;
41			if(result)
42				result = abs(m[i][i] - 1) <= epsilon;
43			for(length_t j = i + 1; result && j < m.length(); ++j)
44				result = abs(m[i][j]) <= epsilon;
45		}
46		return result;
47	}
48
49	template<typename T, precision P>
50	GLM_FUNC_QUALIFIER bool isNormalized(tmat2x2<T, P> const & m, T const & epsilon)
51	{
52		bool result(true);
53		for(length_t i = 0; result && i < m.length(); ++i)
54			result = isNormalized(m[i], epsilon);
55		for(length_t i = 0; result && i < m.length(); ++i)
56		{
57			typename tmat2x2<T, P>::col_type v;
58			for(length_t j = 0; j < m.length(); ++j)
59				v[j] = m[j][i];
60			result = isNormalized(v, epsilon);
61		}
62		return result;
63	}
64
65	template<typename T, precision P>
66	GLM_FUNC_QUALIFIER bool isNormalized(tmat3x3<T, P> const & m, T const & epsilon)
67	{
68		bool result(true);
69		for(length_t i = 0; result && i < m.length(); ++i)
70			result = isNormalized(m[i], epsilon);
71		for(length_t i = 0; result && i < m.length(); ++i)
72		{
73			typename tmat3x3<T, P>::col_type v;
74			for(length_t j = 0; j < m.length(); ++j)
75				v[j] = m[j][i];
76			result = isNormalized(v, epsilon);
77		}
78		return result;
79	}
80
81	template<typename T, precision P>
82	GLM_FUNC_QUALIFIER bool isNormalized(tmat4x4<T, P> const & m, T const & epsilon)
83	{
84		bool result(true);
85		for(length_t i = 0; result && i < m.length(); ++i)
86			result = isNormalized(m[i], epsilon);
87		for(length_t i = 0; result && i < m.length(); ++i)
88		{
89			typename tmat4x4<T, P>::col_type v;
90			for(length_t j = 0; j < m.length(); ++j)
91				v[j] = m[j][i];
92			result = isNormalized(v, epsilon);
93		}
94		return result;
95	}
96
97	template<typename T, precision P, template <typename, precision> class matType>
98	GLM_FUNC_QUALIFIER bool isOrthogonal(matType<T, P> const & m, T const & epsilon)
99	{
100		bool result(true);
101		for(length_t i(0); result && i < m.length() - 1; ++i)
102		for(length_t j(i + 1); result && j < m.length(); ++j)
103			result = areOrthogonal(m[i], m[j], epsilon);
104
105		if(result)
106		{
107			matType<T, P> tmp = transpose(m);
108			for(length_t i(0); result && i < m.length() - 1 ; ++i)
109			for(length_t j(i + 1); result && j < m.length(); ++j)
110				result = areOrthogonal(tmp[i], tmp[j], epsilon);
111		}
112		return result;
113	}
114}//namespace glm
115