Ensure BaseHandle class move noexcept (core public-api)
[platform/core/uifw/dali-core.git] / dali / public-api / math / angle-axis.h
1 #ifndef DALI_ANGLE_AXIS_H
2 #define DALI_ANGLE_AXIS_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <iosfwd>
23 #include <ostream>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/math/radian.h>
27 #include <dali/public-api/math/vector3.h>
28
29 namespace Dali
30 {
31 /**
32  * @addtogroup dali_core_math
33  * @{
34  */
35
36 struct Radian;
37
38 /**
39  * @brief An angle & axis pair.
40  *
41  * This is slightly easier to understand than quaternions for handling rotations
42  * of objects. Both elements should be non-zero to correctly describe a rotation.
43  * @SINCE_1_0.0
44  */
45 struct AngleAxis
46 {
47   /**
48    * @brief Creates an angle-axis pair.
49    * @SINCE_1_0.0
50    */
51   AngleAxis()
52   : angle(0.0f),
53     axis(0.0f, 0.0f, 0.0f)
54   {
55   }
56
57   /**
58    * @brief Creates an angle-axis pair.
59    *
60    * @SINCE_1_0.0
61    * @param[in] initialAngle The initial angle in radians
62    * @param[in] initialAxis The initial axis
63    */
64   AngleAxis(Radian initialAngle, const Vector3& initialAxis)
65   : angle(initialAngle),
66     axis(initialAxis)
67   {
68   }
69
70 public:
71   AngleAxis(const AngleAxis&) = default;            ///< Default copy constructor
72   AngleAxis(AngleAxis&&) noexcept = default;            ///< Default move constructor
73   AngleAxis& operator=(const AngleAxis&) = default; ///< Default copy assignment operator
74   AngleAxis& operator=(AngleAxis&&) noexcept = default;      ///< Default move assignment operator
75
76 public:
77   Radian  angle; ///< The angle in radians
78   Vector3 axis;  ///< The axis
79 };
80
81 // Compiler generated destructor, copy constructor and assignment operators are ok as this class is POD
82
83 /**
84  * @brief Compares two angle axis for equality.
85  *
86  * @SINCE_1_0.0
87  * @param lhs angle axis
88  * @param rhs angle axis
89  * @return True if they are equal
90  */
91 inline bool operator==(const Dali::AngleAxis& lhs, const Dali::AngleAxis& rhs)
92 {
93   return (lhs.angle == rhs.angle) && (lhs.axis == rhs.axis);
94 }
95
96 /**
97  * @brief Prints an angle axis.
98  *
99  * @SINCE_1_1.33
100  * @param[in] o The output stream operator
101  * @param[in] angleAxis The angle axis to print
102  * @return The output stream operator
103  */
104 inline std::ostream& operator<<(std::ostream& o, const Dali::AngleAxis& angleAxis)
105 {
106   return o << "[ Axis: [" << angleAxis.axis.x << ", " << angleAxis.axis.y << ", " << angleAxis.axis.z << "], Angle: " << Degree(angleAxis.angle).degree << " degrees ]";
107 }
108
109 /**
110  * @}
111  */
112 } // namespace Dali
113
114 #endif // DALI_ANGLE_AXIS_H