Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / inc / utils / FUiEffects_UtilsCommon.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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       FUiEffects_UtilsCommon.h
20  * @brief      The common math functions and constants
21  *
22  */
23
24 #ifndef _FUI_EFFECTS_INTERNAL_UTILS_COMMON_H_
25 #define _FUI_EFFECTS_INTERNAL_UTILS_COMMON_H_
26
27 #include <math.h>
28 #include <limits>
29
30 namespace Tizen { namespace Ui { namespace Effects { namespace _Utils
31 {
32         const float     fEPS = std::numeric_limits<float>::epsilon();
33         const double dEPS = std::numeric_limits<double>::epsilon();
34
35         const double dPI_2 = 6.283185307179586232;
36         const double dPI = dPI_2 * 0.5;
37         const float fPI_2 = float(dPI_2);
38         const float fPI = float(dPI);
39
40         const double dDEG2RADCoeff = dPI / 180.0;
41         const double dRAD2DEGCoeff = 180.0 / dPI;
42         const float fDEG2RADCoeff = float(dDEG2RADCoeff);
43         const float fRAD2DEGCoeff = float(dRAD2DEGCoeff);
44
45         inline double dDEG2RAD(double aDEG) {return aDEG * dDEG2RADCoeff;}
46         inline float fDEG2RAD(float aDEG) {return aDEG * fDEG2RADCoeff;}
47         inline double dRAD2DEG(double aRAD) {return aRAD * dRAD2DEGCoeff;}
48         inline float fRAD2DEG(float aRAD) {return aRAD * fRAD2DEGCoeff;}
49
50         enum RotationOrder3 {ROTATION_XYZ = 0, ROTATION_XZY, ROTATION_YXZ, ROTATION_YZX, ROTATION_ZXY, ROTATION_ZYX, ROTATION3_MAX};
51
52         template<class T> inline bool isPowerOf2(T aValue) //only for positive integes
53         {
54             return (aValue & (aValue - T(1))) == T(0);
55         }
56 } } } } //Tizen::Ui::Effects::_Utils
57
58 #endif //_FUI_EFFECTS_INTERNAL_UTILS_COMMON_H_