angle.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Harry Storbacka
27 */
28 
29 
30 #pragma once
31 
32 #include <memory>
33 
34 namespace clan
35 {
38 
39 class Angle_Impl;
40 
41 
44 {
47 };
48 
51 {
57  order_ZYX
58 };
59 
60 
62 class Angle
63 {
66 public:
67 
68 
70  Angle();
71 
73  Angle(float value, AngleUnit unit);
74 
80  static Angle from_radians(float value);
81 
87  static Angle from_degrees(float value);
88 
92 public:
94  float to_degrees() const;
95 
97  float to_radians() const;
98 
102 public:
104  void set_degrees(float value_degrees);
105 
107  void set_radians(float value_radians);
108 
113 
118 
122 public:
124  void operator += (const Angle &angle);
125 
127  void operator -= (const Angle &angle);
128 
130  void operator *= (const Angle &angle);
131 
133  void operator /= (const Angle &angle);
134 
136  Angle operator + (const Angle &angle) const;
137 
139  Angle operator - (const Angle &angle) const;
140 
142  Angle operator * (const Angle &angle) const;
143 
145  Angle operator * (float value) const;
146 
148  Angle operator / (const Angle &angle) const;
149 
151  Angle operator / (float value) const;
152 
154  bool operator < (const Angle &angle) const;
155 
157  bool operator <= (const Angle &angle) const;
158 
160  bool operator > (const Angle &angle) const;
161 
163  bool operator >= (const Angle &angle) const;
164 
166  bool operator== (const Angle &angle) const;
167 
169  bool operator!= (const Angle &angle) const;
170 
174 private:
175  float value_rad;
176 
178 };
179 
180 }
181 
Angle()
Constructs an NULL Angle object.
@ order_ZYX
Definition: angle.h:57
bool operator<(const Angle &angle) const
< operator.
@ angle_degrees
Definition: angle.h:45
static Angle from_degrees(float value)
From degrees.
void operator*=(const Angle &angle)
*= operator.
void operator+=(const Angle &angle)
+= operator.
bool operator>=(const Angle &angle) const
> operator.
@ order_XYZ
Definition: angle.h:52
void set_degrees(float value_degrees)
Set the angle value in degrees.
@ order_YXZ
Definition: angle.h:55
@ order_ZXY
Definition: angle.h:56
Angle class.
Definition: angle.h:63
EulerOrder
Euler angle rotation order.
Definition: angle.h:51
bool operator>(const Angle &angle) const
> operator.
static Angle from_radians(float value)
From radians.
bool operator<=(const Angle &angle) const
< operator.
Angle operator/(const Angle &angle) const
/ operator.
Angle & normalize_180()
Converts angle to range [-180,180] degrees.
AngleUnit
Angle unit.
Definition: angle.h:44
void set_radians(float value_radians)
Set the angle value in radians.
Angle operator+(const Angle &angle) const
operator.
bool operator==(const Angle &angle) const
== operator.
Definition: clanapp.h:36
@ order_YZX
Definition: angle.h:54
Angle(float value, AngleUnit unit)
Constructs an Angle object.
@ order_XZY
Definition: angle.h:53
void operator/=(const Angle &angle)
/= operator.
void operator-=(const Angle &angle)
-= operator.
Angle operator*(const Angle &angle) const
operator.
float to_radians() const
Returns the angle as radians.
@ angle_radians
Definition: angle.h:46
float to_degrees() const
Returns the angle as degrees.
Angle & normalize()
Converts angle to range [0,360] degrees.
Angle operator-(const Angle &angle) const
operator.
bool operator!=(const Angle &angle) const
!= operator.