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.
25 #include <dali/public-api/common/constants.h>
26 #include <dali/public-api/common/dali-common.h>
27 #include <dali/public-api/math/math-utils.h>
35 * @brief An angle in degrees.
37 * This reduces ambiguity when using methods which accept angles in degrees or radians.
42 * @brief default constructor, initialises to 0.
49 * @brief Create an angle in degrees.
51 * @param[in] value The initial value in degrees.
53 explicit Degree( float value )
58 * @brief Create an angle in degrees from a Radian.
60 * @param[in] value The initial value in Radians.
62 DALI_EXPORT_API Degree( Radian value );
67 float degree; ///< The value in degrees
71 // compiler generated destructor, copy constructor and assignment operators are ok as this class is POD
74 * @brief Compare equality between two degrees.
76 * @param[in] lhs Degree to compare
77 * @param[in] rhs Degree to compare to
78 * @return true if the values are identical
80 inline bool operator==( const Degree& lhs, const Degree& rhs )
82 return fabsf( lhs.degree - rhs.degree ) < Math::MACHINE_EPSILON_1000; // expect degree angles to be between 0 and 1000
86 * @brief Compare inequality between two degrees.
88 * @param[in] lhs Degree to compare
89 * @param[in] rhs Degree to compare to
90 * @return true if the values are not identical
92 inline bool operator!=( const Degree& lhs, const Degree& rhs )
94 return !( operator==( lhs, rhs ) );
98 * @brief Clamp a radian value
99 * @param angle to clamp
102 * @return the resulting radian
104 inline Degree Clamp( Degree angle, float min, float max )
106 return Degree( Clamp<float>( angle.degree, min, max ) );
110 * @brief Stream a degree value
111 * @param [in] ostream The output stream to use.
112 * @param [in] angle in Degree.
113 * @return The output stream.
115 inline std::ostream& operator<<( std::ostream& ostream, Degree angle )
117 ostream << angle.degree;
123 #endif // __DALI_DEGREE_H__