angle.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2016 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 #pragma once
30 
31 #include <memory>
32 
33 namespace clan
34 {
37 
38  class Angle_Impl;
39 
41  enum AngleUnit
42  {
45  };
46 
49  {
56  };
57 
59  class Angle
60  {
61  public:
63  Angle();
64 
66  Angle(float value, AngleUnit unit);
67 
73  static Angle from_radians(float value);
74 
80  static Angle from_degrees(float value);
81 
83  float to_degrees() const;
84 
86  float to_radians() const;
87 
89  void set_degrees(float value_degrees);
90 
92  void set_radians(float value_radians);
93 
97  Angle &normalize();
98 
102  Angle &normalize_180();
103 
105  void operator += (const Angle &angle);
106 
108  void operator -= (const Angle &angle);
109 
111  void operator *= (const Angle &angle);
112 
114  void operator /= (const Angle &angle);
115 
117  Angle operator + (const Angle &angle) const;
118 
120  Angle operator - (const Angle &angle) const;
121 
123  Angle operator * (const Angle &angle) const;
124 
126  Angle operator * (float value) const;
127 
129  Angle operator / (const Angle &angle) const;
130 
132  Angle operator / (float value) const;
133 
135  bool operator < (const Angle &angle) const;
136 
138  bool operator <= (const Angle &angle) const;
139 
141  bool operator > (const Angle &angle) const;
142 
144  bool operator >= (const Angle &angle) const;
145 
147  bool operator== (const Angle &angle) const;
148 
150  bool operator!= (const Angle &angle) const;
151 
152  private:
153  float value_rad;
154  };
155 
157 }
Definition: clanapp.h:35
Angle class.
Definition: angle.h:59
Definition: angle.h:55
bool operator<(const Angle &angle) const
< operator.
Definition: angle.h:50
Definition: angle.h:44
bool operator==(const Angle &angle) const
== operator.
Angle operator*(const Angle &angle) const
operator.
static Angle from_degrees(float value)
From degrees.
void set_degrees(float value_degrees)
Set the angle value in degrees.
void operator-=(const Angle &angle)
-= operator.
bool operator!=(const Angle &angle) const
!= operator.
AngleUnit
Angle unit.
Definition: angle.h:41
float to_degrees() const
Returns the angle as degrees.
Definition: angle.h:52
Definition: angle.h:51
bool operator>=(const Angle &angle) const
operator.
Definition: angle.h:53
void operator/=(const Angle &angle)
/= operator.
Definition: angle.h:43
float to_radians() const
Returns the angle as radians.
Angle operator-(const Angle &angle) const
operator.
Definition: angle.h:54
bool operator>(const Angle &angle) const
operator.
Angle operator+(const Angle &angle) const
operator.
Angle operator/(const Angle &angle) const
/ operator.
EulerOrder
Euler angle rotation order.
Definition: angle.h:48
void set_radians(float value_radians)
Set the angle value in radians.
void operator*=(const Angle &angle)
*= operator.
Angle & normalize()
Converts angle to range [0,360] degrees.
bool operator<=(const Angle &angle) const
< operator.
Angle & normalize_180()
Converts angle to range [-180,180] degrees.
Angle()
Constructs a null Angle object.
void operator+=(const Angle &angle)
+= operator.
static Angle from_radians(float value)
From radians.