1/// @ref core
2/// @file glm/detail/type_mat3x2.inl
3
4namespace glm
5{
6	// -- Constructors --
7
8#	if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
9		template <typename T, precision P>
10		GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2()
11		{
12#			ifndef GLM_FORCE_NO_CTOR_INIT
13				this->value[0] = col_type(1, 0);
14				this->value[1] = col_type(0, 1);
15				this->value[2] = col_type(0, 0);
16#			endif
17		}
18#	endif
19
20#	if !GLM_HAS_DEFAULTED_FUNCTIONS
21		template <typename T, precision P>
22		GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat3x2<T, P> const & m)
23		{
24			this->value[0] = m.value[0];
25			this->value[1] = m.value[1];
26			this->value[2] = m.value[2];
27		}
28#	endif//!GLM_HAS_DEFAULTED_FUNCTIONS
29
30	template <typename T, precision P>
31	template <precision Q>
32	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat3x2<T, Q> const & m)
33	{
34		this->value[0] = m.value[0];
35		this->value[1] = m.value[1];
36		this->value[2] = m.value[2];
37	}
38
39	template <typename T, precision P>
40	GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tmat3x2<T, P>::tmat3x2(ctor)
41	{}
42
43	template <typename T, precision P>
44	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(T scalar)
45	{
46		this->value[0] = col_type(scalar, 0);
47		this->value[1] = col_type(0, scalar);
48		this->value[2] = col_type(0, 0);
49	}
50
51	template <typename T, precision P>
52	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2
53	(
54		T x0, T y0,
55		T x1, T y1,
56		T x2, T y2
57	)
58	{
59		this->value[0] = col_type(x0, y0);
60		this->value[1] = col_type(x1, y1);
61		this->value[2] = col_type(x2, y2);
62	}
63
64	template <typename T, precision P>
65	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2
66	(
67		col_type const & v0,
68		col_type const & v1,
69		col_type const & v2
70	)
71	{
72		this->value[0] = v0;
73		this->value[1] = v1;
74		this->value[2] = v2;
75	}
76
77	// -- Conversion constructors --
78
79	template <typename T, precision P>
80	template <
81		typename X1, typename Y1,
82		typename X2, typename Y2,
83		typename X3, typename Y3>
84	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2
85	(
86		X1 x1, Y1 y1,
87		X2 x2, Y2 y2,
88		X3 x3, Y3 y3
89	)
90	{
91		this->value[0] = col_type(static_cast<T>(x1), value_type(y1));
92		this->value[1] = col_type(static_cast<T>(x2), value_type(y2));
93		this->value[2] = col_type(static_cast<T>(x3), value_type(y3));
94	}
95
96	template <typename T, precision P>
97	template <typename V1, typename V2, typename V3>
98	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2
99	(
100		tvec2<V1, P> const & v1,
101		tvec2<V2, P> const & v2,
102		tvec2<V3, P> const & v3
103	)
104	{
105		this->value[0] = col_type(v1);
106		this->value[1] = col_type(v2);
107		this->value[2] = col_type(v3);
108	}
109
110	// -- Matrix conversions --
111
112	template <typename T, precision P>
113	template <typename U, precision Q>
114	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat3x2<U, Q> const & m)
115	{
116		this->value[0] = col_type(m[0]);
117		this->value[1] = col_type(m[1]);
118		this->value[2] = col_type(m[2]);
119	}
120
121	template <typename T, precision P>
122	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat2x2<T, P> const & m)
123	{
124		this->value[0] = m[0];
125		this->value[1] = m[1];
126		this->value[2] = col_type(0);
127	}
128
129	template <typename T, precision P>
130	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat3x3<T, P> const & m)
131	{
132		this->value[0] = col_type(m[0]);
133		this->value[1] = col_type(m[1]);
134		this->value[2] = col_type(m[2]);
135	}
136
137	template <typename T, precision P>
138	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat4x4<T, P> const & m)
139	{
140		this->value[0] = col_type(m[0]);
141		this->value[1] = col_type(m[1]);
142		this->value[2] = col_type(m[2]);
143	}
144
145	template <typename T, precision P>
146	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat2x3<T, P> const & m)
147	{
148		this->value[0] = col_type(m[0]);
149		this->value[1] = col_type(m[1]);
150		this->value[2] = col_type(T(0));
151	}
152
153	template <typename T, precision P>
154	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat2x4<T, P> const & m)
155	{
156		this->value[0] = col_type(m[0]);
157		this->value[1] = col_type(m[1]);
158		this->value[2] = col_type(T(0));
159	}
160
161	template <typename T, precision P>
162	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat3x4<T, P> const & m)
163	{
164		this->value[0] = col_type(m[0]);
165		this->value[1] = col_type(m[1]);
166		this->value[2] = col_type(m[2]);
167	}
168
169	template <typename T, precision P>
170	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat4x2<T, P> const & m)
171	{
172		this->value[0] = m[0];
173		this->value[1] = m[1];
174		this->value[2] = m[2];
175	}
176
177	template <typename T, precision P>
178	GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(tmat4x3<T, P> const & m)
179	{
180		this->value[0] = col_type(m[0]);
181		this->value[1] = col_type(m[1]);
182		this->value[2] = col_type(m[2]);
183	}
184
185	// -- Accesses --
186
187	template <typename T, precision P>
188	GLM_FUNC_QUALIFIER typename tmat3x2<T, P>::col_type & tmat3x2<T, P>::operator[](typename tmat3x2<T, P>::length_type i)
189	{
190		assert(i < this->length());
191		return this->value[i];
192	}
193
194	template <typename T, precision P>
195	GLM_FUNC_QUALIFIER typename tmat3x2<T, P>::col_type const & tmat3x2<T, P>::operator[](typename tmat3x2<T, P>::length_type i) const
196	{
197		assert(i < this->length());
198		return this->value[i];
199	}
200
201	// -- Unary updatable operators --
202
203#	if !GLM_HAS_DEFAULTED_FUNCTIONS
204		template <typename T, precision P>
205		GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator=(tmat3x2<T, P> const & m)
206		{
207			this->value[0] = m[0];
208			this->value[1] = m[1];
209			this->value[2] = m[2];
210			return *this;
211		}
212#	endif//!GLM_HAS_DEFAULTED_FUNCTIONS
213
214	template <typename T, precision P>
215	template <typename U>
216	GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator=(tmat3x2<U, P> const & m)
217	{
218		this->value[0] = m[0];
219		this->value[1] = m[1];
220		this->value[2] = m[2];
221		return *this;
222	}
223
224	template <typename T, precision P>
225	template <typename U>
226	GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator+=(U s)
227	{
228		this->value[0] += s;
229		this->value[1] += s;
230		this->value[2] += s;
231		return *this;
232	}
233
234	template <typename T, precision P>
235	template <typename U>
236	GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator+=(tmat3x2<U, P> const & m)
237	{
238		this->value[0] += m[0];
239		this->value[1] += m[1];
240		this->value[2] += m[2];
241		return *this;
242	}
243
244	template <typename T, precision P>
245	template <typename U>
246	GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator-=(U s)
247	{
248		this->value[0] -= s;
249		this->value[1] -= s;
250		this->value[2] -= s;
251		return *this;
252	}
253
254	template <typename T, precision P>
255	template <typename U>
256	GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator-=(tmat3x2<U, P> const & m)
257	{
258		this->value[0] -= m[0];
259		this->value[1] -= m[1];
260		this->value[2] -= m[2];
261		return *this;
262	}
263
264	template <typename T, precision P>
265	template <typename U>
266	GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator*=(U s)
267	{
268		this->value[0] *= s;
269		this->value[1] *= s;
270		this->value[2] *= s;
271		return *this;
272	}
273
274	template <typename T, precision P>
275	template <typename U>
276	GLM_FUNC_QUALIFIER tmat3x2<T, P> & tmat3x2<T, P>::operator/=(U s)
277	{
278		this->value[0] /= s;
279		this->value[1] /= s;
280		this->value[2] /= s;
281		return *this;
282	}
283
284	// -- Increment and decrement operators --
285
286	template <typename T, precision P>
287	GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator++()
288	{
289		++this->value[0];
290		++this->value[1];
291		++this->value[2];
292		return *this;
293	}
294
295	template <typename T, precision P>
296	GLM_FUNC_QUALIFIER tmat3x2<T, P>& tmat3x2<T, P>::operator--()
297	{
298		--this->value[0];
299		--this->value[1];
300		--this->value[2];
301		return *this;
302	}
303
304	template <typename T, precision P>
305	GLM_FUNC_QUALIFIER tmat3x2<T, P> tmat3x2<T, P>::operator++(int)
306	{
307		tmat3x2<T, P> Result(*this);
308		++*this;
309		return Result;
310	}
311
312	template <typename T, precision P>
313	GLM_FUNC_QUALIFIER tmat3x2<T, P> tmat3x2<T, P>::operator--(int)
314	{
315		tmat3x2<T, P> Result(*this);
316		--*this;
317		return Result;
318	}
319
320	// -- Unary arithmetic operators --
321
322	template <typename T, precision P>
323	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator+(tmat3x2<T, P> const & m)
324	{
325		return m;
326	}
327
328	template <typename T, precision P>
329	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator-(tmat3x2<T, P> const & m)
330	{
331		return tmat3x2<T, P>(
332			-m[0],
333			-m[1],
334			-m[2]);
335	}
336
337	// -- Binary arithmetic operators --
338
339	template <typename T, precision P>
340	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator+(tmat3x2<T, P> const & m, T scalar)
341	{
342		return tmat3x2<T, P>(
343			m[0] + scalar,
344			m[1] + scalar,
345			m[2] + scalar);
346	}
347
348	template <typename T, precision P>
349	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator+(tmat3x2<T, P> const & m1, tmat3x2<T, P> const & m2)
350	{
351		return tmat3x2<T, P>(
352			m1[0] + m2[0],
353			m1[1] + m2[1],
354			m1[2] + m2[2]);
355	}
356
357	template <typename T, precision P>
358	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator-(tmat3x2<T, P> const & m, T scalar)
359	{
360		return tmat3x2<T, P>(
361			m[0] - scalar,
362			m[1] - scalar,
363			m[2] - scalar);
364	}
365
366	template <typename T, precision P>
367	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator-(tmat3x2<T, P> const & m1, tmat3x2<T, P> const & m2)
368	{
369		return tmat3x2<T, P>(
370			m1[0] - m2[0],
371			m1[1] - m2[1],
372			m1[2] - m2[2]);
373	}
374
375	template <typename T, precision P>
376	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator*(tmat3x2<T, P> const & m, T scalar)
377	{
378		return tmat3x2<T, P>(
379			m[0] * scalar,
380			m[1] * scalar,
381			m[2] * scalar);
382	}
383
384	template <typename T, precision P>
385	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator*(T scalar, tmat3x2<T, P> const & m)
386	{
387		return tmat3x2<T, P>(
388			m[0] * scalar,
389			m[1] * scalar,
390			m[2] * scalar);
391	}
392
393	template <typename T, precision P>
394	GLM_FUNC_QUALIFIER typename tmat3x2<T, P>::col_type operator*(tmat3x2<T, P> const & m, typename tmat3x2<T, P>::row_type const & v)
395	{
396		return typename tmat3x2<T, P>::col_type(
397			m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z,
398			m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z);
399	}
400
401	template <typename T, precision P>
402	GLM_FUNC_QUALIFIER typename tmat3x2<T, P>::row_type operator*(typename tmat3x2<T, P>::col_type const & v, tmat3x2<T, P> const & m)
403	{
404		return typename tmat3x2<T, P>::row_type(
405			v.x * m[0][0] + v.y * m[0][1],
406			v.x * m[1][0] + v.y * m[1][1],
407			v.x * m[2][0] + v.y * m[2][1]);
408	}
409
410	template <typename T, precision P>
411	GLM_FUNC_QUALIFIER tmat2x2<T, P> operator*(tmat3x2<T, P> const & m1, tmat2x3<T, P> const & m2)
412	{
413		const T SrcA00 = m1[0][0];
414		const T SrcA01 = m1[0][1];
415		const T SrcA10 = m1[1][0];
416		const T SrcA11 = m1[1][1];
417		const T SrcA20 = m1[2][0];
418		const T SrcA21 = m1[2][1];
419
420		const T SrcB00 = m2[0][0];
421		const T SrcB01 = m2[0][1];
422		const T SrcB02 = m2[0][2];
423		const T SrcB10 = m2[1][0];
424		const T SrcB11 = m2[1][1];
425		const T SrcB12 = m2[1][2];
426
427		tmat2x2<T, P> Result(uninitialize);
428		Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01 + SrcA20 * SrcB02;
429		Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01 + SrcA21 * SrcB02;
430		Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11 + SrcA20 * SrcB12;
431		Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11 + SrcA21 * SrcB12;
432		return Result;
433	}
434
435	template <typename T, precision P>
436	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator*(tmat3x2<T, P> const & m1, tmat3x3<T, P> const & m2)
437	{
438		return tmat3x2<T, P>(
439			m1[0][0] * m2[0][0] + m1[1][0] * m2[0][1] + m1[2][0] * m2[0][2],
440			m1[0][1] * m2[0][0] + m1[1][1] * m2[0][1] + m1[2][1] * m2[0][2],
441			m1[0][0] * m2[1][0] + m1[1][0] * m2[1][1] + m1[2][0] * m2[1][2],
442			m1[0][1] * m2[1][0] + m1[1][1] * m2[1][1] + m1[2][1] * m2[1][2],
443			m1[0][0] * m2[2][0] + m1[1][0] * m2[2][1] + m1[2][0] * m2[2][2],
444			m1[0][1] * m2[2][0] + m1[1][1] * m2[2][1] + m1[2][1] * m2[2][2]);
445	}
446
447	template <typename T, precision P>
448	GLM_FUNC_QUALIFIER tmat4x2<T, P> operator*(tmat3x2<T, P> const & m1, tmat4x3<T, P> const & m2)
449	{
450		return tmat4x2<T, P>(
451			m1[0][0] * m2[0][0] + m1[1][0] * m2[0][1] + m1[2][0] * m2[0][2],
452			m1[0][1] * m2[0][0] + m1[1][1] * m2[0][1] + m1[2][1] * m2[0][2],
453			m1[0][0] * m2[1][0] + m1[1][0] * m2[1][1] + m1[2][0] * m2[1][2],
454			m1[0][1] * m2[1][0] + m1[1][1] * m2[1][1] + m1[2][1] * m2[1][2],
455			m1[0][0] * m2[2][0] + m1[1][0] * m2[2][1] + m1[2][0] * m2[2][2],
456			m1[0][1] * m2[2][0] + m1[1][1] * m2[2][1] + m1[2][1] * m2[2][2],
457			m1[0][0] * m2[3][0] + m1[1][0] * m2[3][1] + m1[2][0] * m2[3][2],
458			m1[0][1] * m2[3][0] + m1[1][1] * m2[3][1] + m1[2][1] * m2[3][2]);
459	}
460
461	template <typename T, precision P>
462	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator/(tmat3x2<T, P> const & m, T scalar)
463	{
464		return tmat3x2<T, P>(
465			m[0] / scalar,
466			m[1] / scalar,
467			m[2] / scalar);
468	}
469
470	template <typename T, precision P>
471	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator/(T scalar, tmat3x2<T, P> const & m)
472	{
473		return tmat3x2<T, P>(
474			scalar / m[0],
475			scalar / m[1],
476			scalar / m[2]);
477	}
478
479	// -- Boolean operators --
480
481	template <typename T, precision P>
482	GLM_FUNC_QUALIFIER bool operator==(tmat3x2<T, P> const & m1, tmat3x2<T, P> const & m2)
483	{
484		return (m1[0] == m2[0]) && (m1[1] == m2[1]) && (m1[2] == m2[2]);
485	}
486
487	template <typename T, precision P>
488	GLM_FUNC_QUALIFIER bool operator!=(tmat3x2<T, P> const & m1, tmat3x2<T, P> const & m2)
489	{
490		return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]);
491	}
492} //namespace glm
493