1/// @ref gtx_matrix_transform_2d
2/// @file glm/gtc/matrix_transform_2d.inl
3/// @author Miguel Ángel Pérez Martínez
4
5#include "../trigonometric.hpp"
6
7namespace glm
8{
9
10	template <typename T, precision P>
11	GLM_FUNC_QUALIFIER tmat3x3<T, P> translate(
12		tmat3x3<T, P> const & m,
13		tvec2<T, P> const & v)
14	{
15		tmat3x3<T, P> Result(m);
16		Result[2] = m[0] * v[0] + m[1] * v[1] + m[2];
17		return Result;
18	}
19
20
21	template <typename T, precision P>
22	GLM_FUNC_QUALIFIER tmat3x3<T, P> rotate(
23		tmat3x3<T, P> const & m,
24		T angle)
25	{
26		T const a = angle;
27		T const c = cos(a);
28		T const s = sin(a);
29
30		tmat3x3<T, P> Result(uninitialize);
31		Result[0] = m[0] * c + m[1] * s;
32		Result[1] = m[0] * -s + m[1] * c;
33		Result[2] = m[2];
34		return Result;
35	}
36
37	template <typename T, precision P>
38	GLM_FUNC_QUALIFIER tmat3x3<T, P> scale(
39		tmat3x3<T, P> const & m,
40		tvec2<T, P> const & v)
41	{
42		tmat3x3<T, P> Result(uninitialize);
43		Result[0] = m[0] * v[0];
44		Result[1] = m[1] * v[1];
45		Result[2] = m[2];
46		return Result;
47	}
48
49	template <typename T, precision P>
50	GLM_FUNC_QUALIFIER tmat3x3<T, P> shearX(
51		tmat3x3<T, P> const & m,
52		T y)
53	{
54		tmat3x3<T, P> Result(1);
55		Result[0][1] = y;
56		return m * Result;
57	}
58
59	template <typename T, precision P>
60	GLM_FUNC_QUALIFIER tmat3x3<T, P> shearY(
61		tmat3x3<T, P> const & m,
62		T x)
63	{
64		tmat3x3<T, P> Result(1);
65		Result[1][0] = x;
66		return m * Result;
67	}
68
69}//namespace glm
70