]> git.sesse.net Git - casparcg/blob - SFML-1.6/include/SFML/Graphics/Matrix3.hpp
(no commit message)
[casparcg] / SFML-1.6 / include / SFML / Graphics / Matrix3.hpp
1 ////////////////////////////////////////////////////////////\r
2 //\r
3 // SFML - Simple and Fast Multimedia Library\r
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\r
5 //\r
6 // This software is provided 'as-is', without any express or implied warranty.\r
7 // In no event will the authors be held liable for any damages arising from the use of this software.\r
8 //\r
9 // Permission is granted to anyone to use this software for any purpose,\r
10 // including commercial applications, and to alter it and redistribute it freely,\r
11 // subject to the following restrictions:\r
12 //\r
13 // 1. The origin of this software must not be misrepresented;\r
14 //    you must not claim that you wrote the original software.\r
15 //    If you use this software in a product, an acknowledgment\r
16 //    in the product documentation would be appreciated but is not required.\r
17 //\r
18 // 2. Altered source versions must be plainly marked as such,\r
19 //    and must not be misrepresented as being the original software.\r
20 //\r
21 // 3. This notice may not be removed or altered from any source distribution.\r
22 //\r
23 ////////////////////////////////////////////////////////////\r
24 \r
25 #ifndef SFML_MATRIX3_HPP\r
26 #define SFML_MATRIX3_HPP\r
27 \r
28 ////////////////////////////////////////////////////////////\r
29 // Headers\r
30 ////////////////////////////////////////////////////////////\r
31 #include <SFML/Config.hpp>\r
32 #include <SFML/System/Vector2.hpp>\r
33 #include <math.h>\r
34 \r
35 \r
36 namespace sf\r
37 {\r
38 ////////////////////////////////////////////////////////////\r
39 /// Utility class to manipulate 3x3 matrices representing\r
40 /// 2D transformations\r
41 ////////////////////////////////////////////////////////////\r
42 class SFML_API Matrix3\r
43 {\r
44 public :\r
45 \r
46     ////////////////////////////////////////////////////////////\r
47     /// Default constructor (builds an identity matrix)\r
48     ///\r
49     ////////////////////////////////////////////////////////////\r
50     Matrix3();\r
51 \r
52     ////////////////////////////////////////////////////////////\r
53     /// Construct a matrix from its 9 elements\r
54     ///\r
55     ////////////////////////////////////////////////////////////\r
56     Matrix3(float a00, float a01, float a02,\r
57             float a10, float a11, float a12,\r
58             float a20, float a21, float a22);\r
59 \r
60     ////////////////////////////////////////////////////////////\r
61     /// Build a matrix from a set of transformations\r
62     ///\r
63     /// \param Center :      Origin for the transformations\r
64     /// \param Translation : Translation offset\r
65     /// \param Rotation :    Rotation angle in degrees\r
66     /// \param Scale :       Scaling factors\r
67     ///\r
68     ////////////////////////////////////////////////////////////\r
69     void SetFromTransformations(const Vector2f& Center, const Vector2f& Translation, float Rotation, const Vector2f& Scale);\r
70 \r
71     ////////////////////////////////////////////////////////////\r
72     /// Transform a point by the matrix\r
73     ///\r
74     /// \param Point : Point to transform\r
75     ///\r
76     /// \return Transformed point\r
77     ///\r
78     ////////////////////////////////////////////////////////////\r
79     Vector2f Transform(const Vector2f& Point) const;\r
80 \r
81     ////////////////////////////////////////////////////////////\r
82     /// Return the inverse of the matrix\r
83     ///\r
84     /// \return A new matrix which is the inverse of this\r
85     ///\r
86     ////////////////////////////////////////////////////////////\r
87     Matrix3 GetInverse() const;\r
88 \r
89     ////////////////////////////////////////////////////////////\r
90     /// Return the elements of the matrix as a 4x4,\r
91     /// in an array of 16 floats\r
92     ///\r
93     /// \return Pointer to the 4x4 matrix elements\r
94     ///\r
95     ////////////////////////////////////////////////////////////\r
96     const float* Get4x4Elements() const;\r
97 \r
98     ////////////////////////////////////////////////////////////\r
99     /// Operator () overloads to access the matrix elements\r
100     ///\r
101     /// \param Row : Element row (0 based)\r
102     /// \param Col : Element column (0 based)\r
103     ///\r
104     /// \return Matrix element (Row, Col)\r
105     ///\r
106     ////////////////////////////////////////////////////////////\r
107     float  operator ()(unsigned int Row, unsigned int Col) const;\r
108     float& operator ()(unsigned int Row, unsigned int Col);\r
109 \r
110     ////////////////////////////////////////////////////////////\r
111     /// Operator * overload to multiply two matrices\r
112     ///\r
113     /// \param Mat : Matrix to multiply\r
114     ///\r
115     /// \return this * Mat\r
116     ///\r
117     ////////////////////////////////////////////////////////////\r
118     Matrix3 operator *(const Matrix3& Mat) const;\r
119 \r
120     ////////////////////////////////////////////////////////////\r
121     /// Operator *= overload to multiply-assign two matrices\r
122     ///\r
123     /// \param Mat : Matrix to multiply\r
124     ///\r
125     /// \return this * Mat\r
126     ///\r
127     ////////////////////////////////////////////////////////////\r
128     Matrix3& operator *=(const Matrix3& Mat);\r
129 \r
130     ////////////////////////////////////////////////////////////\r
131     // Static member data\r
132     ////////////////////////////////////////////////////////////\r
133     static const Matrix3 Identity; ///< Identity matrix\r
134 \r
135 private :\r
136 \r
137     ////////////////////////////////////////////////////////////\r
138     // Member data\r
139     ////////////////////////////////////////////////////////////\r
140     float myData[16]; /// Matrix elements (we directly store it as a 4x4 matrix for optimization purpose)\r
141 };\r
142 \r
143 #include <SFML/Graphics/Matrix3.inl>\r
144 \r
145 } // namespace sf\r
146 \r
147 \r
148 #endif // SFML_MATRIX3_HPP\r