Rev Author Line No. Line
23 ovan 1 ///////////////////////////////////////////////////////////////////////////////////
2 /// OpenGL Mathematics (glm.g-truc.net)
3 ///
4 /// Copyright (c) 2005 - 2015 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 /// Restrictions:
16 /// By making use of the Software for military purposes, you choose to make
17 /// a Bunny unhappy.
18 ///
19 /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 /// THE SOFTWARE.
26 ///
27 /// @ref gtx_matrix_transform_2d
28 /// @file glm/gtc/matrix_transform_2d.inl
29 /// @date 2014-02-20
30 /// @author Miguel Ángel Pérez Martínez
31 ///////////////////////////////////////////////////////////////////////////////////
32  
33 #include "../trigonometric.hpp"
34  
35 namespace glm
36 {
37  
38 template <typename T, precision P>
39 GLM_FUNC_QUALIFIER tmat3x3<T, P> translate(
40 tmat3x3<T, P> const & m,
41 tvec2<T, P> const & v)
42 {
43 tmat3x3<T, P> Result(m);
44 Result[2] = m[0] * v[0] + m[1] * v[1] + m[2];
45 return Result;
46 }
47  
48  
49 template <typename T, precision P>
50 GLM_FUNC_QUALIFIER tmat3x3<T, P> rotate(
51 tmat3x3<T, P> const & m,
52 T angle)
53 {
54 T const a = angle;
55 T const c = cos(a);
56 T const s = sin(a);
57  
58 tmat3x3<T, P> Result(uninitialize);
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 tmat3x3<T, P> scale(
67 tmat3x3<T, P> const & m,
68 tvec2<T, P> const & v)
69 {
70 tmat3x3<T, P> Result(uninitialize);
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 tmat3x3<T, P> shearX(
79 tmat3x3<T, P> const & m,
80 T y)
81 {
82 tmat3x3<T, P> Result(1);
83 Result[0][1] = y;
84 return m * Result;
85 }
86  
87 template <typename T, precision P>
88 GLM_FUNC_QUALIFIER tmat3x3<T, P> shearY(
89 tmat3x3<T, P> const & m,
90 T x)
91 {
92 tmat3x3<T, P> Result(1);
93 Result[1][0] = x;
94 return m * Result;
95 }
96  
97 }//namespace glm