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.
24 #ifndef _FBASE_FLOAT_MATRIX4_H_
25 #define _FBASE_FLOAT_MATRIX4_H_
28 #include <FBaseTypes.h>
29 #include <FBaseObject.h>
31 namespace Tizen { namespace Base
35 * @brief This class encapsulates a 4 X 4 matrix.
39 * The %FloatMatrix4 class provides a @c float precision, two-dimensional matrix class.
42 class _OSP_EXPORT_ FloatMatrix4
43 : public Tizen::Base::Object
47 * This is the default constructor for this class. @n
48 * Constructs a 4 X 4 null matrix in which all elements are zero.
55 * Copying of objects using this copy constructor is allowed.
59 * @param[in] rhs An instance of %FloatMatrix4
61 FloatMatrix4(const FloatMatrix4& rhs);
64 * Constructs a 4 by 4 matrix initialized to the value in the specified array.
68 * @param[in] matrix The matrix with 16 @c float values
70 FloatMatrix4(const float matrix[4][4]);
73 * TThis destructor overrides Tizen::Base::Object::~Object().
77 virtual ~FloatMatrix4(void);
80 * Checks whether the current instance and the specified instance of %FloatMatrix4 are equal.
84 * @return @c true if all matrix members of the current instance are equal to the corresponding matrix members in the specified instance, @n
86 * @param[in] rhs An instance of %FloatMatrix4
88 bool operator ==(const FloatMatrix4& rhs) const;
91 * Checks whether the current instance and the specified instance of %FloatMatrix4 are not equal.
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
97 * @param[in] rhs An instance of %FloatMatrix4
99 bool operator !=(const FloatMatrix4& rhs) const;
102 * Copying of objects using this copy assignment operator is allowed.
106 * @return The reference to this instance
107 * @param[in] rhs An instance of %FloatMatrix4
109 FloatMatrix4& operator =(const FloatMatrix4& rhs);
112 * Assigns the value of the specified instance to the current instance of %FloatMatrix4.
116 * @return The reference to this instance
117 * @param[in] value A @c float value to assign
119 FloatMatrix4& operator =(float value);
122 * Multiplies the value of the specified instance with the current instance of %FloatMatrix4.
126 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
127 * @param[in] rhs An instance of %FloatMatrix4
129 FloatMatrix4 operator *(const FloatMatrix4& rhs) const;
132 * Multiplies the value to each matrix members of current instance of %FloatMatrix4.
136 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
137 * @param[in] value A @c float value to multiply
139 FloatMatrix4 operator *(float value) const;
142 * Adds the value of the specified instance and the current instance of %FloatMatrix4.
146 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
147 * @param[in] rhs An instance of %FloatMatrix4
149 FloatMatrix4 operator +(const FloatMatrix4& rhs) const;
152 * Adds the value to each matrix members of current instance of %FloatMatrix4.
156 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
157 * @param[in] value A @c float value to add
159 FloatMatrix4 operator +(float value) const;
162 * Subtracts the value of the specified instance and the current instance of %FloatMatrix4.
166 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
167 * @param[in] rhs An instance of %FloatMatrix4
169 FloatMatrix4 operator -(const FloatMatrix4& rhs) const;
172 * Subtracts the value from each matrix members of current instance of %FloatMatrix4.
176 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
177 * @param[in] value A @c float value to subtract
179 FloatMatrix4 operator -(float value) const;
182 * Multiplies the value of the specified instance and the current instance of %FloatMatrix4.
186 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
187 * @param[in] rhs An instance of %FloatMatrix4
189 FloatMatrix4& operator *=(const FloatMatrix4& rhs);
192 * Multiplies the value to each matrix members of current instance of %FloatMatrix4.
196 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
197 * @param[in] value A @c float value to multiply
199 FloatMatrix4& operator *=(float value);
202 * Adds the value of the specified instance to the current instance of %FloatMatrix4.
206 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
207 * @param[in] rhs An instance of %FloatMatrix4
209 FloatMatrix4& operator +=(const FloatMatrix4& rhs);
212 * Adds the value to each matrix members of current instance of %FloatMatrix4.
216 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
217 * @param[in] value A @c float value to add
219 FloatMatrix4& operator +=(float value);
222 * Subtracts the value of the specified instance from the current instance of %FloatMatrix4.
226 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
227 * @param[in] rhs An instance of %FloatMatrix4
229 FloatMatrix4& operator -=(const FloatMatrix4& rhs);
232 * Subtracts the value from each matrix members of current instance of %FloatMatrix4.
236 * @return The reference to %FloatMatrix4 containing the resulting value of the operation
237 * @param[in] value A @c float value to subtract
239 FloatMatrix4& operator -=(float value);
242 * Gets the instance of %FloatMatrix4 resulting from the sum of the value and the specified instance of %FloatMatrix4.
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
250 _OSP_EXPORT_ friend FloatMatrix4 operator +(const float& value, const FloatMatrix4& rhs);
253 * Gets the instance of %FloatMatrix4 resulting from the product of the value and the specified instance of %FloatMatrix4.
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
261 _OSP_EXPORT_ friend FloatMatrix4 operator *(const float& value, const FloatMatrix4& rhs);
264 * Gets the instance of %FloatMatrix4 resulting from the difference between the value and the specified instance of %FloatMatrix4.
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
272 _OSP_EXPORT_ friend FloatMatrix4 operator -(const float& value, const FloatMatrix4& rhs);
275 * Checks whether the current instance of %FloatMatrix4 equals the specified instance of %FloatMatrix4.
279 * @return @c true if the values of the current instance is equal to the value of the specified instance, @n
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.
284 virtual bool Equals(const Tizen::Base::Object& obj) const;
287 * Gets the hash value of the current instance of %FloatMatrix4.
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.
295 virtual int GetHashCode(void) const;
298 * Gets the determinant of the current instance of %FloatMatrix4.
302 * @return The determinant value of the current instance
304 float GetDeterminant(void) const;
307 * Gets the inverse matrix of the current instance of %FloatMatrix4.
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.
314 FloatMatrix4 GetInverse(void) const;
317 * Gets the trace of the current instance of %FloatMatrix4.
321 * @return The trace of the current instance
323 float GetTrace(void) const;
326 * Gets the transpose matrix of the current instance of %FloatMatrix4.
330 * @return A new instance of %FloatMatrix4 containing the resulting value of the operation
332 FloatMatrix4 GetTranspose(void) const;
335 * Checks whether the current instance is an identity matrix.
339 * @return @c true if the matrix is an identity matrix, @n
342 bool IsIdentity(void) const;
345 * Checks whether the current matrix is invertible.
349 * @return @c true if the matrix is invertible, @n
352 bool IsInvertible(void) const;
355 * Negates the matrix members of current instance of %FloatMatrix4.
362 * Sets the identity matrix to the current instance of %FloatMatrix4.
366 void SetAsIdentity(void);
369 * Sets the inverse matrix to the current instance of %FloatMatrix4.
373 * @return An error code
374 * @exception E_SUCCESS The method is successful.
375 * @exception E_INVALID_OPERATION The current instance is not invertible.
380 * Sets the transposed matrix to the current instance of %FloatMatrix4.
384 void Transpose(void);
387 * Sets the matrix members of current instance of %FloatMatrix4 to zero.
391 void SetAsNull(void);
394 * The matrix of the current instance of %FloatMatrix4.
398 * @remarks The column-major order matrix.
403 friend class _FloatMatrix4Impl;
404 class _FloatMatrix4Impl* __pImpl;
410 #endif //_FBASE_FLOAT_MATRIX4_H_