1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
---|---|
2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
3 | #include "Prerequisites/BsPrerequisitesUtil.h" |
4 | #include "Math/BsRadian.h" |
5 | #include "Math/BsMath.h" |
6 | |
7 | namespace bs |
8 | { |
9 | Radian::Radian (const Degree& d) : mRad(d.valueRadians()) |
10 | { } |
11 | |
12 | Radian Radian::wrap() |
13 | { |
14 | mRad = fmod(mRad, Math::TWO_PI); |
15 | |
16 | if (mRad < 0) |
17 | mRad += Math::TWO_PI; |
18 | |
19 | return *this; |
20 | } |
21 | |
22 | Radian& Radian::operator= (const Degree& d) |
23 | { |
24 | mRad = d.valueRadians(); |
25 | return *this; |
26 | } |
27 | |
28 | Radian Radian::operator+ (const Degree& d) const |
29 | { |
30 | return Radian (mRad + d.valueRadians()); |
31 | } |
32 | |
33 | Radian& Radian::operator+= (const Degree& d) |
34 | { |
35 | mRad += d.valueRadians(); |
36 | return *this; |
37 | } |
38 | |
39 | Radian Radian::operator- (const Degree& d) const |
40 | { |
41 | return Radian (mRad - d.valueRadians()); |
42 | } |
43 | |
44 | Radian& Radian::operator-= (const Degree& d) |
45 | { |
46 | mRad -= d.valueRadians(); |
47 | return *this; |
48 | } |
49 | |
50 | float Radian::valueDegrees() const |
51 | { |
52 | return mRad * Math::RAD2DEG; |
53 | } |
54 | } |
55 |