2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FBaseFloatMatrix4.h
19 * @brief This is the header file for the %FloatMatrix4 class.
21 * This header file contains the declarations of the %FloatMatrix4 class.
25 #ifndef _FBASE_FLOAT_MATRIX4_H_
26 #define _FBASE_FLOAT_MATRIX4_H_
29 #include <FBaseTypes.h>
30 #include <FBaseObject.h>
32 namespace Tizen { namespace Base
36 * @brief This class encapsulates a 4 X 4 matrix.
40 * The %FloatMatrix4 class provides a @c float precision, two-dimensional matrix class.
43 class _OSP_EXPORT_ FloatMatrix4
44 : public Tizen::Base::Object
48 * This is the default constructor for this class. @n
49 * Constructs a 4 X 4 null matrix in which all elements are zero.
56 * Copying of objects using this copy constructor is allowed.
60 * @param[in] rhs An instance of %FloatMatrix4
62 FloatMatrix4(const FloatMatrix4& rhs);
65 * Constructs a 4 by 4 matrix initialized to the value in the specified array.
69 * @param[in] matrix The matrix with 16 @c float values
71 FloatMatrix4(const float matrix[4][4]);
74 * TThis destructor overrides Tizen::Base::Object::~Object().
78 virtual ~FloatMatrix4(void);
81 * Checks whether the current instance and the specified instance of %FloatMatrix4 are equal.
85 * @return @c true if all matrix members of the current instance are equal to the corresponding matrix members in the specified instance, @n
87 * @param[in] rhs An instance of %FloatMatrix4
89 bool operator ==(const FloatMatrix4& rhs) const;
92 * Checks whether the current instance and the specified instance of %FloatMatrix4 are not equal.
96 * @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 * @param[in] rhs An instance of %FloatMatrix4
100 bool operator !=(const FloatMatrix4& rhs) const;
103 * Copying of objects using this copy assignment operator is allowed.
107 * @return The reference to this instance
108 * @param[in] rhs An instance of %FloatMatrix4
110 FloatMatrix4& operator =(const FloatMatrix4& rhs);
113 * Assigns the value of the specified instance to the current instance of %FloatMatrix4.
117 * @return The reference to this instance
118 * @param[in] value A @c float value to assign
120 FloatMatrix4& operator =(float value);
123 * Multiplies the value of the specified instance with the current instance of %FloatMatrix4.
127 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
128 * @param[in] rhs An instance of %FloatMatrix4
130 FloatMatrix4 operator *(const FloatMatrix4& rhs) const;
133 * Multiplies the value to each matrix members of current instance of %FloatMatrix4.
137 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
138 * @param[in] value A @c float value to multiply
140 FloatMatrix4 operator *(float value) const;
143 * Adds the value of the specified instance and the current instance of %FloatMatrix4.
147 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
148 * @param[in] rhs An instance of %FloatMatrix4
150 FloatMatrix4 operator +(const FloatMatrix4& rhs) const;
153 * Adds the value to each matrix members of current instance of %FloatMatrix4.
157 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
158 * @param[in] value A @c float value to add
160 FloatMatrix4 operator +(float value) const;
163 * Subtracts the value of the specified instance and the current instance of %FloatMatrix4.
167 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
168 * @param[in] rhs An instance of %FloatMatrix4
170 FloatMatrix4 operator -(const FloatMatrix4& rhs) const;
173 * Subtracts the value from each matrix members of current instance of %FloatMatrix4.
177 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
178 * @param[in] value A @c float value to subtract
180 FloatMatrix4 operator -(float value) const;
183 * Multiplies the value of the specified instance and the current instance of %FloatMatrix4.
187 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
188 * @param[in] rhs An instance of %FloatMatrix4
190 FloatMatrix4& operator *=(const FloatMatrix4& rhs);
193 * Multiplies the value to each matrix members of current instance of %FloatMatrix4.
197 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
198 * @param[in] value A @c float value to multiply
200 FloatMatrix4& operator *=(float value);
203 * Adds the value of the specified instance to the current instance of %FloatMatrix4.
207 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
208 * @param[in] rhs An instance of %FloatMatrix4
210 FloatMatrix4& operator +=(const FloatMatrix4& rhs);
213 * Adds the value to each matrix members of current instance of %FloatMatrix4.
217 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
218 * @param[in] value A @c float value to add
220 FloatMatrix4& operator +=(float value);
223 * Subtracts the value of the specified instance from the current instance of %FloatMatrix4.
227 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
228 * @param[in] rhs An instance of %FloatMatrix4
230 FloatMatrix4& operator -=(const FloatMatrix4& rhs);
233 * Subtracts the value from each matrix members of current instance of %FloatMatrix4.
237 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
238 * @param[in] value A @c float value to subtract
240 FloatMatrix4& operator -=(float value);
243 * Gets the instance of %FloatMatrix4 resulting from the sum of the value and the specified instance of %FloatMatrix4.
247 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
248 * @param[in] value A @c float value to add
249 * @param[in] rhs An instance of %FloatMatrix4
251 _OSP_EXPORT_ friend FloatMatrix4 operator +(const float& value, const FloatMatrix4& rhs);
254 * Gets the instance of %FloatMatrix4 resulting from the product of the value and the specified instance of %FloatMatrix4.
258 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
259 * @param[in] value A @c float value to multiply
260 * @param[in] rhs An instance of %FloatMatrix4
262 _OSP_EXPORT_ friend FloatMatrix4 operator *(const float& value, const FloatMatrix4& rhs);
265 * Gets the instance of %FloatMatrix4 resulting from the difference between the value and the specified instance of %FloatMatrix4.
269 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
270 * @param[in] value A @c float value to subtract
271 * @param[in] rhs An instance of %FloatMatrix4
273 _OSP_EXPORT_ friend FloatMatrix4 operator -(const float& value, const FloatMatrix4& rhs);
276 * Checks whether the current instance of %FloatMatrix4 equals the specified instance of %FloatMatrix4.
280 * @return @c true if the values of the current instance is equal to the value of the specified instance, @n
282 * @param[in] obj An instance of %FloatMatrix4
283 * @remarks This method overrides Tizen::Base::Object::Equals(). This method uses the values of the Matrix components to compare the two instances.
285 virtual bool Equals(const Tizen::Base::Object& obj) const;
288 * Gets the hash value of the current instance of %FloatMatrix4.
292 * @return The hash value of the current instance
293 * @remarks Two equal instances must return the same hash value. For better performance,
294 * the used hash function must generate a random distribution for all inputs.
296 virtual int GetHashCode(void) const;
299 * Gets the determinant of the current instance of %FloatMatrix4.
303 * @return The determinant value of the current instance
305 float GetDeterminant(void) const;
308 * Gets the inverse matrix of the current instance of %FloatMatrix4.
312 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
313 * @remarks This function must be called after checking whether the matrix is invertible or not.
315 FloatMatrix4 GetInverse(void) const;
318 * Gets the trace of the current instance of %FloatMatrix4.
322 * @return The trace of the current instance
324 float GetTrace(void) const;
327 * Gets the transpose matrix of the current instance of %FloatMatrix4.
331 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
333 FloatMatrix4 GetTranspose(void) const;
336 * Checks whether the current instance is an identity matrix.
340 * @return @c true if the matrix is an identity matrix, @n
343 bool IsIdentity(void) const;
346 * Checks whether the current matrix is invertible.
350 * @return @c true if the matrix is invertible, @n
353 bool IsInvertible(void) const;
356 * Negates the matrix members of current instance of %FloatMatrix4.
363 * Sets the identity matrix to the current instance of %FloatMatrix4.
367 void SetAsIdentity(void);
370 * Sets the inverse matrix to the current instance of %FloatMatrix4.
374 * @return An error code
375 * @exception E_SUCCESS The method is successful.
376 * @exception E_INVALID_OPERATION The current instance is not invertible.
381 * Sets the transposed matrix to the current instance of %FloatMatrix4.
385 void Transpose(void);
388 * Sets the matrix members of current instance of %FloatMatrix4 to zero.
392 void SetAsNull(void);
395 * The matrix of the current instance of %FloatMatrix4.
399 * @remarks The column-major order matrix.
404 friend class _FloatMatrix4Impl;
405 class _FloatMatrix4Impl* __pImpl;
411 #endif //_FBASE_FLOAT_MATRIX4_H_