angle.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 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
33namespace clan
34{
37
38 class Angle_Impl;
39
41 enum class AngleUnit
42 {
43 degrees,
45 };
46
48 enum class EulerOrder
49 {
50 XYZ,
51 XZY,
52 YZX,
53 YXZ,
54 ZXY,
55 ZYX
56 };
57
59 class Angle
60 {
61 public:
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
98
103
106
109
112
115
118
121
124
126 Angle operator * (float value) const;
127
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}
Angle class.
Definition: angle.h:60
Angle operator-(const Angle &angle) const
operator.
Angle & normalize_180()
Converts angle to range [-180,180] degrees.
bool operator<=(const Angle &angle) const
< operator.
Angle(float value, AngleUnit unit)
Constructs an Angle object.
bool operator<(const Angle &angle) const
< operator.
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.
void operator+=(const Angle &angle)
+= operator.
Angle operator/(const Angle &angle) const
/ operator.
Angle operator*(const Angle &angle) const
operator.
Angle operator+(const Angle &angle) const
operator.
float to_radians() const
Returns the angle as radians.
void set_radians(float value_radians)
Set the angle value in radians.
void operator-=(const Angle &angle)
-= operator.
Angle()
Constructs a null Angle object.
bool operator>(const Angle &angle) const
> operator.
bool operator!=(const Angle &angle) const
!= operator.
void set_degrees(float value_degrees)
Set the angle value in degrees.
Angle & normalize()
Converts angle to range [0,360] degrees.
float to_degrees() const
Returns the angle as degrees.
bool operator>=(const Angle &angle) const
> operator.
static Angle from_radians(float value)
From radians.
AngleUnit
Angle unit.
Definition: angle.h:42
EulerOrder
Euler angle rotation order.
Definition: angle.h:49
Definition: clanapp.h:36
@ angle
value is a color