Merge "Fix Ime Rotation" into tizen_2.1
[platform/framework/native/uifw.git] / inc / FGrpFloatMatrix4.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FGrpFloatMatrix4.h
20  * @brief       This is the header file for the %FloatMatrix4 class.
21  *
22  * This header file contains the declarations of the %FloatMatrix4 class.
23  *
24  */
25
26 #ifndef _FGRP_FLOAT_MATRIX4_H_
27 #define _FGRP_FLOAT_MATRIX4_H_
28
29 #include <FBaseObject.h>
30
31 namespace Tizen { namespace Graphics
32 {
33 class FloatVector4;
34 }}
35
36 namespace Tizen { namespace Graphics
37 {
38 /**
39  * @class       FloatMatrix4
40  * @brief       This class encapsulates a 4 X 4 matrix.
41  *
42  * @since 2.0
43  *
44  * The %FloatMatrix4 class provides a float precision, two-dimensional matrix class.
45  *
46  */
47 class _OSP_EXPORT_ FloatMatrix4
48         : public Tizen::Base::Object
49 {
50 public:
51         /**
52          * This is the default constructor for this class. @n
53          * This constructor initializes a 4 X 4 identity matrix.
54          *
55          * @since 2.0
56          */
57         FloatMatrix4(void);
58
59         /**
60          * This is the copy constructor for the %FloatMatrix4 class. @n
61          * This constructor initializes the instance of %FloatMatrix4 with the attributes of the specified instance of %FloatMatrix4.
62          *
63          * @since 2.0
64          *
65          * @param[in]   rhs     An instance of %FloatMatrix4
66          */
67         FloatMatrix4(const FloatMatrix4& rhs);
68
69         /**
70          * This constructor initializes the instance of %FloatMatrix4 with the attributes of the specified instance of the array.
71          *
72          * @since 2.0
73          *
74          * @param[in]   matrix  The matrix with 16 float values
75          */
76         FloatMatrix4(const float matrix[4][4]);
77
78         /**
79          * This is the destructor for this class.
80          *
81          * @since 2.0
82          */
83         virtual ~FloatMatrix4(void);
84
85         /**
86          * Checks whether the current instance and the specified instance of %FloatMatrix4 are equal.
87          *
88          * @since 2.0
89          *
90          * @return      @c true if all matrix members of the current instance are equal to the corresponding matrix members in the specified instance, @n
91          *                      else @c false
92          * @param[in]   rhs     An instance of %FloatMatrix4
93          */
94         bool operator ==(const FloatMatrix4& rhs) const;
95
96         /**
97          * Checks whether the current instance and the specified instance of %FloatMatrix4 are not equal.
98          *
99          * @since 2.0
100          *
101          * @return      @c true if all matrix members of the current instance are not equal to the corresponding matrix members in the specified instance, @n
102          *                      else @c false
103          * @param[in]   rhs     An instance of %FloatMatrix4
104          */
105         bool operator !=(const FloatMatrix4& rhs) const;
106
107         /**
108          * Assigns the values of the specified instance to the current instance of %FloatMatrix4.
109          *
110          * @since 2.0
111          *
112          * @return      The reference to this instance
113          * @param[in]   rhs     An instance of %FloatMatrix4
114          */
115         FloatMatrix4& operator =(const FloatMatrix4& rhs);
116
117         /**
118          * Assigns the value to each matrix members of current instance of %FloatMatrix4.
119          *
120          * @since 2.0
121          *
122          * @return      The reference to this instance
123          * @param[in]   value   A @c float value to assign
124          */
125         FloatMatrix4& operator =(float value);
126
127         /**
128          * Multiplies the value of the specified instance with the current instance of %FloatMatrix4.
129          *
130          * @since 2.0
131          *
132          * @return      A new instance of %FloatMatrix4 containing the resulting value of the operation
133          * @param[in]   rhs     An instance of %FloatMatrix4
134          */
135         FloatMatrix4 operator *(const FloatMatrix4& rhs) const;
136
137         /**
138          * Multiplies the current instance of %FloatMatrix4 with %FloatVector4.
139          *
140          * @since 2.0
141          *
142          * @return      A new instance of %FloatVector4 containing the resulting value of the operation
143          * @param[in]   vector  An instance of %FloatVector4
144          */
145         FloatVector4 operator *(const FloatVector4& vector) const;
146
147         /**
148          * Multiplies the value to each matrix members of current instance of %FloatMatrix4.
149          *
150          * @since 2.0
151          *
152          * @return      A new instance of %FloatMatrix4 containing the resulting value of the operation
153          * @param[in]   value   A @c float value to multiply
154          */
155         FloatMatrix4 operator *(float value) const;
156
157         /**
158          * Adds the value of the specified instance and the current instance of %FloatMatrix4.
159          *
160          * @since 2.0
161          *
162          * @return      A new instance of %FloatMatrix4 containing the resulting value of the operation
163          * @param[in]   rhs     An instance of %FloatMatrix4
164          */
165         FloatMatrix4 operator +(const FloatMatrix4& rhs) const;
166
167         /**
168          * Adds the value to each matrix members of current instance of %FloatMatrix4.
169          *
170          * @since 2.0
171          *
172          * @return      A new instance of %FloatMatrix4 containing the resulting value of the operation
173          * @param[in]   value   A @c float value to add
174          */
175         FloatMatrix4 operator +(float value) const;
176
177         /**
178          * Subtracts the value of the specified instance and the current instance of %FloatMatrix4.
179          *
180          * @since 2.0
181          *
182          * @return      A new instance of %FloatMatrix4 containing the resulting value of the operation
183          * @param[in]   rhs     An instance of %FloatMatrix4
184          */
185         FloatMatrix4 operator -(const FloatMatrix4& rhs) const;
186
187         /**
188          * Subtracts the value from each matrix members of current instance of %FloatMatrix4.
189          *
190          * @since 2.0
191          *
192          * @return      A new instance of %FloatMatrix4 containing the resulting value of the operation
193          * @param[in]   value   A @c float value to subtract
194          */
195         FloatMatrix4 operator -(float value) const;
196
197         /**
198          * Multiplies the value of the specified instance and the current instance of %FloatMatrix4.
199          *
200          * @since 2.0
201          *
202          * @return      The reference to %FloatMatrix4 containing the resulting value of the operation
203          * @param[in]   rhs     An instance of %FloatMatrix4
204          */
205         FloatMatrix4& operator *=(const FloatMatrix4& rhs);
206
207         /**
208          * Multiplies the value to each matrix members of current instance of %FloatMatrix4.
209          *
210          * @since 2.0
211          *
212          * @return      The reference to %FloatMatrix4 containing the resulting value of the operation
213          * @param[in]   value   A @c float value to multiply
214          */
215         FloatMatrix4& operator *=(float value);
216
217         /**
218          * Adds the value of the specified instance to the current instance of %FloatMatrix4.
219          *
220          * @since 2.0
221          *
222          * @return      The reference to %FloatMatrix4 containing the resulting value of the operation
223          * @param[in]   rhs     An instance of %FloatMatrix4
224          */
225         FloatMatrix4& operator +=(const FloatMatrix4& rhs);
226
227         /**
228          * Adds the value to each matrix members of current instance of %FloatMatrix4.
229          *
230          * @since 2.0
231          *
232          * @return      The reference to %FloatMatrix4 containing the resulting value of the operation
233          * @param[in]   value   A @c float value to add
234          */
235         FloatMatrix4& operator +=(float value);
236
237         /**
238          * Subtracts the value of the specified instance from the current instance of %FloatMatrix4.
239          *
240          * @since 2.0
241          *
242          * @return      The reference to %FloatMatrix4 containing the resulting value of the operation
243          * @param[in]   rhs     An instance of %FloatMatrix4
244          */
245         FloatMatrix4& operator -=(const FloatMatrix4& rhs);
246
247         /**
248          * Subtracts the value from each matrix members of current instance of %FloatMatrix4.
249          *
250          * @since 2.0
251          *
252          * @return      The reference to %FloatMatrix4 containing the resulting value of the operation
253          * @param[in]   value   A @c float value to subtract
254          */
255         FloatMatrix4& operator -=(float value);
256
257         /**
258          * Gets the instance of %FloatMatrix4 resulting from the sum of the value and the specified instance of %FloatMatrix4.
259          *
260          * @since 2.0
261          *
262          * @return      A new instance of %FloatMatrix4 containing the resulting value of the operation
263          * @param[in]   value   A @c float value to add
264          * @param[in]   rhs     An instance of %FloatMatrix4
265          */
266         _OSP_EXPORT_ friend FloatMatrix4 operator +(const float& value, const FloatMatrix4& rhs);
267
268         /**
269          * Gets the instance of %FloatMatrix4 resulting from the product of the value and the specified instance of %FloatMatrix4.
270          *
271          * @since 2.0
272          *
273          * @return      A new instance of %FloatMatrix4 containing the resulting value of the operation
274          * @param[in]   value   A @c float value to multiply
275          * @param[in]   rhs     An instance of %FloatMatrix4
276          */
277         _OSP_EXPORT_ friend FloatMatrix4 operator *(const float& value, const FloatMatrix4& rhs);
278
279         /**
280          * Gets the instance of %FloatMatrix4 resulting from the difference between the value and the specified instance of %FloatMatrix4.
281          *
282          * @since 2.0
283          *
284          * @return      A new instance of %FloatMatrix4 containing the resulting value of the operation
285          * @param[in]   value   A @c float value to subtract
286          * @param[in]   rhs     An instance of %FloatMatrix4
287          */
288         _OSP_EXPORT_ friend FloatMatrix4 operator -(const float& value, const FloatMatrix4& rhs);
289
290         /**
291          * Checks whether the current instance of %FloatMatrix4 equals the specified instance of %FloatMatrix4.
292          *
293          * @since 2.0
294          *
295          * @return      @c true if the values of the current instance is equal to the value of the specified instance, @n
296          *                      else @c false
297          * @param[in]   obj     An instance of %FloatMatrix4
298          * @remarks     This method overrides Tizen::Base::Object::Equals(). This method uses the values of the Matrix components to compare the two instances.
299          */
300         virtual bool Equals(const Tizen::Base::Object& obj) const;
301
302         /**
303          * Gets the hash value of the current instance of %FloatMatrix4.
304          *
305          * @since 2.0
306          *
307          * @return      The hash value of the current instance
308          * @remarks     Two equal instances must return the same hash value. For better performance,
309          *                              the used hash function must generate a random distribution for all inputs.
310          */
311         virtual int GetHashCode(void) const;
312
313         /**
314          * Gets the determinant of the current instance of %FloatMatrix4.
315          *
316          * @since 2.0
317          *
318          * @return      The determinant value of the current instance
319          */
320         float GetDeterminant(void) const;
321
322         /**
323          * Gets the inverse matrix of the current instance of %FloatMatrix4.
324          *
325          * @since 2.0
326          *
327          * @return      A new instance of %FloatMatrix4 containing the resulting value of the operation
328          * @remarks     This method must be called after checking whether the matrix is invertible or not.
329          */
330         FloatMatrix4 GetInverse(void) const;
331
332         /**
333          * Gets the trace of the current instance of %FloatMatrix4.
334          *
335          * @since 2.0
336          *
337          * @return      The trace of the current instance
338          */
339         float GetTrace(void) const;
340
341         /**
342          * Gets the transpose matrix of the current instance of %FloatMatrix4.
343          *
344          * @since 2.0
345          *
346          * @return      A new instance of %FloatMatrix4 containing the resulting value of the operation
347          */
348         FloatMatrix4 GetTranspose(void) const;
349
350         /**
351          * Checks whether the current instance is an identity matrix.
352          *
353          * @since 2.0
354          *
355          * @return      @c true if the matrix is an identity matrix, @n
356          *                      else @c false
357          */
358         bool IsIdentity(void) const;
359
360         /**
361          * Checks whether the current matrix is invertible.
362          *
363          * @since 2.0
364          *
365          * @return      @c true if the matrix is invertible, @n
366          *                      else @c false
367          */
368         bool IsInvertible(void) const;
369
370         /**
371          * Negates the matrix members of current instance of %FloatMatrix4.
372          *
373          * @since 2.0
374          */
375         void Negate(void);
376
377         /**
378          * Sets the identity matrix to the current instance of %FloatMatrix4.
379          *
380          * @since 2.0
381          */
382         void SetAsIdentity(void);
383
384         /**
385          * Sets the inverse matrix to the current instance of %FloatMatrix4.
386          *
387          * @since 2.0
388          *
389          * @return              An error code
390          * @exception   E_SUCCESS       The method is successful.
391          * @exception   E_INVALID_OPERATION     The current instance is not invertible.
392          */
393         result Invert(void);
394
395         /**
396          * Sets the transposed matrix to the current instance of %FloatMatrix4.
397          *
398          * @since 2.0
399          */
400         void Transpose(void);
401
402         /**
403          * Sets the matrix members of current instance of %FloatMatrix4 to zero.
404          *
405          * @since 2.0
406          */
407         void SetAsNull(void);
408
409         /**
410          * The matrix of the current instance of %FloatMatrix4.
411          *
412          * @since 2.0
413          *
414          * @remarks     The column-major order matrix.
415          */
416         float matrix[4][4];
417
418 private:
419         friend class _FloatMatrix4Impl;
420         class _FloatMatrix4Impl* __pImpl;
421
422 }; // FloatMatrix4
423
424 }} // Tizen::Graphics
425
426 #endif //_FGRP_FLOAT_MATRIX4_H_