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
43 enum AngleUnit
44 {
45 angle_degrees,
46 angle_radians
47 };
48
50 enum EulerOrder
51 {
52 order_XYZ,
53 order_XZY,
54 order_YZX,
55 order_YXZ,
56 order_ZXY,
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
112 Angle &normalize();
113
117 Angle &normalize_180();
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
clan::Angle::Angle
Angle()
Constructs an NULL Angle object.
clan
Definition: clanapp.h:35
clan::Angle::normalize
Angle & normalize()
Converts angle to range [0,360] degrees.
clan::Angle
Angle class.
Definition: angle.h:62
clan::Angle::operator+=
void operator+=(const Angle &angle)
+= operator.
clan::order_ZYX
Definition: angle.h:57
clan::order_XYZ
Definition: angle.h:52
clan::Angle::operator!=
bool operator!=(const Angle &angle) const
!= operator.
clan::angle_radians
Definition: angle.h:46
clan::Angle::operator/
Angle operator/(const Angle &angle) const
/ operator.
clan::Angle::to_radians
float to_radians() const
Returns the angle as radians.
clan::AngleUnit
AngleUnit
Angle unit.
Definition: angle.h:43
clan::Angle::to_degrees
float to_degrees() const
Returns the angle as degrees.
clan::order_YZX
Definition: angle.h:54
clan::order_XZY
Definition: angle.h:53
clan::StyleValueType::angle
value is a color
clan::order_YXZ
Definition: angle.h:55
clan::angle_degrees
Definition: angle.h:45
clan::Angle::operator>=
bool operator>=(const Angle &angle) const
operator.
clan::order_ZXY
Definition: angle.h:56
clan::Angle::set_degrees
void set_degrees(float value_degrees)
Set the angle value in degrees.
clan::Angle::operator<=
bool operator<=(const Angle &angle) const
< operator.
clan::EulerOrder
EulerOrder
Euler angle rotation order.
Definition: angle.h:50
clan::Angle::operator-=
void operator-=(const Angle &angle)
-= operator.
clan::Angle::operator==
bool operator==(const Angle &angle) const
== operator.
clan::Angle::from_radians
static Angle from_radians(float value)
From radians.
clan::Angle::operator/=
void operator/=(const Angle &angle)
/= operator.
clan::Angle::operator<
bool operator<(const Angle &angle) const
< operator.
clan::Angle::operator>
bool operator>(const Angle &angle) const
operator.
clan::Angle::from_degrees
static Angle from_degrees(float value)
From degrees.
clan::Angle::normalize_180
Angle & normalize_180()
Converts angle to range [-180,180] degrees.
clan::Angle::operator*
Angle operator*(const Angle &angle) const
operator.
clan::Angle::operator*=
void operator*=(const Angle &angle)
*= operator.
clan::Angle::operator+
Angle operator+(const Angle &angle) const
operator.
clan::Angle::set_radians
void set_radians(float value_radians)
Set the angle value in radians.
clan::Angle::operator-
Angle operator-(const Angle &angle) const
operator.