angle.h Source File - ClanLib SDK
Description: angle.h Source File

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,
44 radians
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:
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}
clan::Angle
Angle class.
Definition angle.h:60
clan::Angle::operator-
Angle operator-(const Angle &angle) const
operator.
clan::Angle::normalize_180
Angle & normalize_180()
Converts angle to range [-180,180] degrees.
clan::Angle::operator<=
bool operator<=(const Angle &angle) const
< operator.
clan::Angle::Angle
Angle(float value, AngleUnit unit)
Constructs an Angle object.
clan::Angle::operator<
bool operator<(const Angle &angle) const
< operator.
clan::Angle::from_degrees
static Angle from_degrees(float value)
From degrees.
clan::Angle::operator/=
void operator/=(const Angle &angle)
/= operator.
clan::Angle::operator*=
void operator*=(const Angle &angle)
*= operator.
clan::Angle::operator==
bool 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::operator*
Angle operator*(const Angle &angle) const
operator.
clan::Angle::operator+
Angle operator+(const Angle &angle) const
operator.
clan::Angle::to_radians
float to_radians() const
Returns the angle as radians.
clan::Angle::set_radians
void set_radians(float value_radians)
Set the angle value in radians.
clan::Angle::operator-=
void operator-=(const Angle &angle)
-= operator.
clan::Angle::Angle
Angle()
Constructs a null Angle object.
clan::Angle::operator>
bool operator>(const Angle &angle) const
> operator.
clan::Angle::operator!=
bool operator!=(const Angle &angle) const
!= operator.
clan::Angle::set_degrees
void set_degrees(float value_degrees)
Set the angle value in degrees.
clan::Angle::normalize
Angle & normalize()
Converts angle to range [0,360] degrees.
clan::Angle::to_degrees
float to_degrees() const
Returns the angle as degrees.
clan::Angle::operator>=
bool operator>=(const Angle &angle) const
> operator.
clan::Angle::from_radians
static Angle from_radians(float value)
From radians.
clan::AngleUnit
AngleUnit
Angle unit.
Definition angle.h:42
clan::EulerOrder
EulerOrder
Euler angle rotation order.
Definition angle.h:49
clan::AngleUnit::radians
@ radians
clan::AngleUnit::degrees
@ degrees
clan::EulerOrder::ZXY
@ ZXY
clan::EulerOrder::YXZ
@ YXZ
clan::EulerOrder::ZYX
@ ZYX
clan::EulerOrder::XZY
@ XZY
clan::EulerOrder::YZX
@ YZX
clan::EulerOrder::XYZ
@ XYZ
clan
Definition clanapp.h:36
clan::StyleValueType::angle
@ angle
value is a color