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