• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1///////////////////////////////////////////////////////////////////////////////////
2/// OpenGL Mathematics (glm.g-truc.net)
3///
4/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
5/// Permission is hereby granted, free of charge, to any person obtaining a copy
6/// of this software and associated documentation files (the "Software"), to deal
7/// in the Software without restriction, including without limitation the rights
8/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9/// copies of the Software, and to permit persons to whom the Software is
10/// furnished to do so, subject to the following conditions:
11///
12/// The above copyright notice and this permission notice shall be included in
13/// all copies or substantial portions of the Software.
14///
15/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21/// THE SOFTWARE.
22///
23/// @ref gtx_matrix_transform_2d
24/// @file glm/gtc/matrix_transform_2d.inl
25/// @date 2014-02-20
26/// @author Miguel Ángel Pérez Martínez
27///////////////////////////////////////////////////////////////////////////////////
28
29#include "../trigonometric.hpp"
30
31namespace glm
32{
33
34	template <typename T, precision P>
35	GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> translate(
36		detail::tmat3x3<T, P> const & m,
37		detail::tvec2<T, P> const & v)
38	{
39		detail::tmat3x3<T, P> Result(m);
40		Result[2] = m[0] * v[0] + m[1] * v[1] + m[2];
41		return Result;
42	}
43
44
45	template <typename T, precision P>
46	GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> rotate(
47		detail::tmat3x3<T, P> const & m,
48		T const & angle)
49	{
50	#ifdef GLM_FORCE_RADIANS
51		T a = angle;
52	#else
53		T a = radians(angle);
54	#endif
55		T c = cos(a);
56		T s = sin(a);
57
58		detail::tmat3x3<T, P> Result(detail::tmat3x3<T, P>::_null);
59		Result[0] = m[0] * c + m[1] * s;
60		Result[1] = m[0] * -s + m[1] * c;
61		Result[2] = m[2];
62		return Result;
63	}
64
65	template <typename T, precision P>
66	GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> scale(
67		detail::tmat3x3<T, P> const & m,
68		detail::tvec2<T, P> const & v)
69	{
70		detail::tmat3x3<T, P> Result(detail::tmat3x3<T, P>::_null);
71		Result[0] = m[0] * v[0];
72		Result[1] = m[1] * v[1];
73		Result[2] = m[2];
74		return Result;
75	}
76
77	template <typename T, precision P>
78	GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> shearX(
79		detail::tmat3x3<T, P> const & m,
80		T const & y)
81	{
82		detail::tmat3x3<T, P> Result();
83		Result[0][1] = y;
84		return m * Result;
85	}
86
87	template <typename T, precision P>
88	GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> shearY(
89		detail::tmat3x3<T, P> const & m,
90		T const & x)
91	{
92		detail::tmat3x3<T, P> Result();
93		Result[1][0] = x;
94		return m * Result;
95	}
96
97}//namespace glm
98