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