1 #ifndef __DALI_DEGREE_H__
2 #define __DALI_DEGREE_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/constants.h>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/public-api/math/math-utils.h>
29 * @addtogroup dali_core_math
36 * @brief An angle in degrees.
38 * This reduces ambiguity when using methods which accept angles in degrees or radians.
44 * @brief default constructor, initialises to 0.
52 * @brief Create an angle in degrees.
55 * @param[in] value The initial value in degrees.
57 explicit Degree( float value )
62 * @brief Create an angle in degrees from a Radian.
65 * @param[in] value The initial value in Radians.
67 DALI_EXPORT_API Degree( Radian value );
72 float degree; ///< The value in degrees
76 // compiler generated destructor, copy constructor and assignment operators are ok as this class is POD
78 // useful constant angles
79 DALI_EXPORT_API extern const Radian ANGLE_360; ///< 360 degree turn in radians
80 DALI_EXPORT_API extern const Radian ANGLE_315; ///< 315 degree turn in radians
81 DALI_EXPORT_API extern const Radian ANGLE_270; ///< 270 degree turn in radians
82 DALI_EXPORT_API extern const Radian ANGLE_225; ///< 225 degree turn in radians
83 DALI_EXPORT_API extern const Radian ANGLE_180; ///< 180 degree turn in radians
84 DALI_EXPORT_API extern const Radian ANGLE_135; ///< 135 degree turn in radians
85 DALI_EXPORT_API extern const Radian ANGLE_120; ///< 120 degree turn in radians
86 DALI_EXPORT_API extern const Radian ANGLE_90; ///< 90 degree turn in radians
87 DALI_EXPORT_API extern const Radian ANGLE_60; ///< 60 degree turn in radians
88 DALI_EXPORT_API extern const Radian ANGLE_45; ///< 45 degree turn in radians
89 DALI_EXPORT_API extern const Radian ANGLE_30; ///< 30 degree turn in radians
90 DALI_EXPORT_API extern const Radian ANGLE_0; ///< 0 degree turn in radians
93 * @brief Compare equality between two degrees.
96 * @param[in] lhs Degree to compare
97 * @param[in] rhs Degree to compare to
98 * @return true if the values are identical
100 inline bool operator==( const Degree& lhs, const Degree& rhs )
102 return fabsf( lhs.degree - rhs.degree ) < Math::MACHINE_EPSILON_1000; // expect degree angles to be between 0 and 1000
106 * @brief Compare inequality between two degrees.
109 * @param[in] lhs Degree to compare
110 * @param[in] rhs Degree to compare to
111 * @return true if the values are not identical
113 inline bool operator!=( const Degree& lhs, const Degree& rhs )
115 return !( operator==( lhs, rhs ) );
119 * @brief Clamp a radian value
121 * @param angle to clamp
124 * @return the resulting radian
126 inline Degree Clamp( Degree angle, float min, float max )
128 return Degree( Clamp<float>( angle.degree, min, max ) );
136 #endif // __DALI_DEGREE_H__