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