Simulant  21.12-194
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
degrees.h
1 #pragma once
2 
3 namespace smlt {
4 
5 struct Radians;
6 
7 struct Degrees {
8  Degrees():
9  value(0) {}
10 
11  explicit Degrees(float value):
12  value(value) {}
13 
14  Degrees(const Radians& rhs);
15 
16  float value;
17 
18  Degrees operator-() const {
19  Degrees ret = *this;
20  ret.value = -ret.value;
21  return ret;
22  }
23 
24  Degrees operator-=(const Degrees& rhs) const {
25  Degrees ret = *this;
26  ret.value -= rhs.value;
27  return ret;
28  }
29 
30  Degrees operator+=(const Degrees& rhs) const {
31  Degrees ret = *this;
32  ret.value += rhs.value;
33  return ret;
34  }
35 
36  bool operator==(const Degrees& rhs) const {
37  return value == rhs.value;
38  }
39 
40  bool operator!=(const Degrees& rhs) const {
41  return !(*this == rhs);
42  }
43 
44  bool is_effectively_equal_to(const Degrees& rhs, float epsilon=0.0f) {
45  // Returns equal if the values represent basically the same thing (e.g. -90 == 270)
46  float rhs_v = rhs.value;
47  if(rhs_v < 0) rhs_v += 360.0f;
48 
49  float lhs_v = value;
50  if(lhs_v < 0) lhs_v += 360.0f;
51 
52  return lhs_v - epsilon < rhs_v && lhs_v + epsilon > rhs_v;
53  }
54 };
55 
56 Degrees to_degrees(const Radians& radians);
57 Degrees lerp_angle(Degrees a, Degrees b, float t);
58 
59 }
smlt::Radians
Definition: radians.h:7
smlt
Definition: animation.cpp:25
smlt::Degrees
Definition: degrees.h:7