sync with tizen_2.0
[platform/framework/native/appfw.git] / inc / FBaseDoubleMatrix3.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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        FBaseDoubleMatrix3.h
20  * @brief       This is the header file for the %DoubleMatrix3 class.
21  *
22  * This header file contains the declarations of the %DoubleMatrix3 class.
23  *
24  */
25
26 #ifndef _FBASE_DOUBLE_MATRIX3_H_
27 #define _FBASE_DOUBLE_MATRIX3_H_
28
29 #include <FBase.h>
30 #include <FBaseTypes.h>
31 #include <FBaseObject.h>
32
33 namespace Tizen { namespace Base
34 {
35 /**
36  * @class       DoubleMatrix3
37  * @brief       This class encapsulates a 3 X 3 matrix.
38  *
39  * @since 2.0
40  *
41  * The %DoubleMatrix3 class provides a @c double precision, two-dimensional matrix class.
42  *
43  */
44 class _OSP_EXPORT_ DoubleMatrix3
45         : public Tizen::Base::Object
46 {
47 public:
48         /**
49          * This is the default constructor for this class. @n
50          * Constructs a 3 X 3 null matrix in which all elements are zero.
51          *
52          * @since 2.0
53          */
54         DoubleMatrix3(void);
55
56         /**
57          * Copying of objects using this copy constructor is allowed.
58          *
59          * @since 2.0
60          *
61          * @param[in]   rhs     An instance of %DoubleMatrix3
62          */
63         DoubleMatrix3(const DoubleMatrix3& rhs);
64
65         /**
66          * Constructs a 3 by 3 matrix initialized to the value in the specified array.
67          *
68          * @since 2.0
69          *
70          * @param[in]   matrix  The matrix with 9 @c double values
71          */
72         DoubleMatrix3(const double matrix[3][3]);
73
74         /**
75          * This destructor overrides Tizen::Base::Object::~Object().
76          *
77          * @since 2.0
78          */
79         virtual ~DoubleMatrix3(void);
80
81         /**
82          * Checks whether the current instance and the specified instance of %DoubleMatrix3 are equal.
83          *
84          * @since 2.0
85          *
86          * @return      @c true if all matrix members of the current instance are equal to the corresponding matrix members in the specified instance, @n
87          *                      else @c false
88          * @param[in]   rhs     An instance of %DoubleMatrix3
89          */
90         bool operator ==(const DoubleMatrix3& rhs) const;
91
92         /**
93          * Checks whether the current instance and the specified instance of %DoubleMatrix3 are not equal.
94          *
95          * @since 2.0
96          *
97          * @return      @c true if all matrix members of the current instance are not equal to the corresponding matrix members in the specified instance, @n
98          *                      else @c false
99          * @param[in]   rhs     An instance of %DoubleMatrix3
100          */
101         bool operator !=(const DoubleMatrix3& rhs) const;
102
103         /**
104          * Copying of objects using this copy assignment operator is allowed.
105          *
106          * @since 2.0
107          *
108          * @return      The reference to this instance
109          * @param[in]   rhs     An instance of %DoubleMatrix3
110          */
111         DoubleMatrix3& operator =(const DoubleMatrix3& rhs);
112
113         /**
114          * Assigns the value of the specified instance to the current instance of %DoubleMatrix3.
115          *
116          * @since 2.0
117          *
118          * @return      The reference to this instance
119          * @param[in]   value   A @c double value to assign
120          */
121         DoubleMatrix3& operator =(double value);
122
123         /**
124          * Multiplies the value of the specified instance with the current instance of %DoubleMatrix3.
125          *
126          * @since 2.0
127          *
128          * @return      A new instance of %DoubleMatrix3 containing the resulting value of the operation
129          * @param[in]   rhs     An instance of %DoubleMatrix3
130          */
131         DoubleMatrix3 operator *(const DoubleMatrix3& rhs) const;
132
133         /**
134          * Multiplies the value to each matrix members of current instance of %DoubleMatrix3.
135          *
136          * @since 2.0
137          *
138          * @return      A new instance of %DoubleMatrix3 containing the resulting value of the operation
139          * @param[in]   value   A @c double value to multiply
140          */
141         DoubleMatrix3 operator *(double value) const;
142
143         /**
144          * Adds the value of the specified instance and the current instance of %DoubleMatrix3.
145          *
146          * @since 2.0
147          *
148          * @return      A new instance of %DoubleMatrix3 containing the resulting value of the operation
149          * @param[in]   rhs     An instance of %DoubleMatrix3
150          */
151         DoubleMatrix3 operator +(const DoubleMatrix3& rhs) const;
152
153         /**
154          * Adds the value to each matrix members of current instance of %DoubleMatrix3.
155          *
156          * @since 2.0
157          *
158          * @return      A new instance of %DoubleMatrix3 containing the resulting value of the operation
159          * @param[in]   value   A @c double value to add
160          */
161         DoubleMatrix3 operator +(double value) const;
162
163         /**
164          * Subtracts the value of the specified instance and the current instance of %DoubleMatrix3.
165          *
166          * @since 2.0
167          *
168          * @return      A new instance of %DoubleMatrix3 containing the resulting value of the operation
169          * @param[in]   rhs     An instance of %DoubleMatrix3
170          */
171         DoubleMatrix3 operator -(const DoubleMatrix3& rhs) const;
172
173         /**
174          * Subtracts the value from each matrix members of current instance of %DoubleMatrix3.
175          *
176          * @since 2.0
177          *
178          * @return      A new instance of %DoubleMatrix3 containing the resulting value of the operation
179          * @param[in]   value   A @c double value to subtract
180          */
181         DoubleMatrix3 operator -(double value) const;
182
183         /**
184          * Multiplies the value of the specified instance and the current instance of %DoubleMatrix3.
185          *
186          * @since 2.0
187          *
188          * @return      The reference to %DoubleMatrix3 containing the resulting value of the operation
189          * @param[in]   rhs     An instance of %DoubleMatrix3
190          */
191         DoubleMatrix3& operator *=(const DoubleMatrix3& rhs);
192
193         /**
194          * Multiplies the value to each matrix members of current instance of %DoubleMatrix3.
195          *
196          * @since 2.0
197          *
198          * @return      The reference to %DoubleMatrix3 containing the resulting value of the operation
199          * @param[in]   value   A @c double value to multiply
200          */
201         DoubleMatrix3& operator *=(double value);
202
203         /**
204          * Adds the value of the specified instance to the current instance of %DoubleMatrix3.
205          *
206          * @since 2.0
207          *
208          * @return      The reference to %DoubleMatrix3 containing the resulting value of the operation
209          * @param[in]   rhs     An instance of %DoubleMatrix3
210          */
211         DoubleMatrix3& operator +=(const DoubleMatrix3& rhs);
212
213         /**
214          * Adds the value to each matrix members of current instance of %DoubleMatrix3.
215          *
216          * @since 2.0
217          *
218          * @return      The reference to %DoubleMatrix3 containing the resulting value of the operation
219          * @param[in]   value   A @c double value to add
220          */
221         DoubleMatrix3& operator +=(double value);
222
223         /**
224          * Subtracts the value of the specified instance from the current instance of %DoubleMatrix3.
225          *
226          * @since 2.0
227          *
228          * @return      The reference to %DoubleMatrix3 containing the resulting value of the operation
229          * @param[in]   rhs     An instance of %DoubleMatrix3
230          */
231         DoubleMatrix3& operator -=(const DoubleMatrix3& rhs);
232
233         /**
234          * Subtracts the value from each matrix members of current instance of %DoubleMatrix3.
235          *
236          * @since 2.0
237          *
238          * @return      The reference to %DoubleMatrix3 containing the resulting value of the operation
239          * @param[in]   value   A @c double value to subtract
240          */
241         DoubleMatrix3& operator -=(double value);
242
243         /**
244          * Gets the instance of %DoubleMatrix3 resulting from the sum of the value and the specified instance of %DoubleMatrix3.
245          *
246          * @since 2.0
247          *
248          * @return      A new instance of %DoubleMatrix3 containing the resulting value of the operation
249          * @param[in]   value   A @c double value to add
250          * @param[in]   rhs     An instance of %DoubleMatrix3
251          */
252         _OSP_EXPORT_ friend DoubleMatrix3 operator +(const double& value, const DoubleMatrix3& rhs);
253
254         /**
255          * Gets the instance of %DoubleMatrix3 resulting from the product of the value and the specified instance of %DoubleMatrix3.
256          *
257          * @since 2.0
258          *
259          * @return      A new instance of %DoubleMatrix3 containing the resulting value of the operation
260          * @param[in]   value   A @c double value to multiply
261          * @param[in]   rhs     An instance of %DoubleMatrix3
262          */
263         _OSP_EXPORT_ friend DoubleMatrix3 operator *(const double& value, const DoubleMatrix3& rhs);
264
265         /**
266          * Gets the instance of %DoubleMatrix3 resulting from the difference between the value and the specified instance of %DoubleMatrix3.
267          *
268          * @since 2.0
269          *
270          * @return      A new instance of %DoubleMatrix3 containing the resulting value of the operation
271          * @param[in]   value   A @c double value to subtract
272          * @param[in]   rhs     An instance of %DoubleMatrix3
273          */
274         _OSP_EXPORT_ friend DoubleMatrix3 operator -(const double& value, const DoubleMatrix3& rhs);
275
276         /**
277          * Checks whether the current instance of %DoubleMatrix3 equals the specified instance of %DoubleMatrix3.
278          *
279          * @since 2.0
280          *
281          * @return      @c true if the values of the current instance is equal to the value of the specified instance, @n
282          *                      else @c false
283          * @param[in]   obj     An instance of %DoubleMatrix3
284          * @remarks     This method overrides Tizen::Base::Object::Equals(). 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. For better performance,
295          *                              the used hash function must generate a random distribution for all 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 containing the resulting value of the operation
314          * @remarks     This function 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 containing 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 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 to the current instance of %DoubleMatrix3.
383          *
384          * @since 2.0
385          */
386         void Transpose(void);
387
388         /**
389          * Sets the matrix members of 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
410 }}// Tizen::Base
411
412 #endif //_FBASE_DOUBLE_MATRIX3_H_