Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
c_angle.h
Go to the documentation of this file.
1#ifndef C_ANGLE_H
2#define C_ANGLE_H
3
5
6class cSAngle {
7private:
9
10public:
11 const static cSAngle _0;
12 const static cSAngle _1;
13 const static cSAngle _90;
14 const static cSAngle _180;
15 const static cSAngle _270;
16#ifdef __MWERKS__
19 cSAngle(const cSAngle&);
20#else
21 cSAngle() = default;
22 ~cSAngle() = default;
23 cSAngle(const cSAngle&) = default;
24#endif
25 cSAngle(s16);
26 cSAngle(float);
27 s16 Val() const { return this->mAngle; }
28 // void Set(s16 angle) { this->mAngle = angle; }
29 void Val(const cSAngle&);
30 void Val(s16);
31 void Val(float);
32 float Degree(void) const;
33 float Radian(void) const;
34 float Norm(void) const;
35 s16 Abs(void) const;
36 s16 Inv(void) const;
37 float Sin(void) const;
38 float Cos(void) const;
39 cSAngle operator-(void) const;
40 cSAngle operator+(const cSAngle&) const;
41 cSAngle operator-(const cSAngle&) const;
42 void operator+=(const cSAngle&);
43 void operator-=(const cSAngle&);
44 cSAngle operator+(short) const;
45 cSAngle operator-(short) const;
46 void operator+=(short);
47 cSAngle operator*(float) const;
48 void operator*=(float);
49 bool operator<(const cSAngle& other) const { return mAngle < other.mAngle; }
50 bool operator>(const cSAngle& other) const { return mAngle > other.mAngle; }
51 bool operator<=(const cSAngle& other) const { return mAngle <= other.mAngle; }
52 bool operator>=(const cSAngle& other) const { return mAngle >= other.mAngle; }
53 bool operator==(const cSAngle& other) const { return mAngle == other.mAngle; }
54 operator s16(void) const { return mAngle; }
55 void operator=(const cSAngle& other) { mAngle = other.mAngle; }
56 static inline cSAngle getMaxNegative(void) { return cSAngle((s16)-0x8000); }
57 inline void mirrorAtMaxNeg(void) { *this = cSAngle((s16)-0x8000) - *this; }
58};
59
60cSAngle operator+(short, const cSAngle&);
61cSAngle operator-(short, const cSAngle&);
62
63struct cAngle {
64 static f32 Radian_to_Degree(f32 rad) { return rad * 57.2957763671875f; }
65 static f32 Degree_to_Radian(f32 deg) { return deg * 0.017453292f; }
66 static s16 Degree_to_SAngle(f32 deg) { return deg * 182.04444885253906f; }
67 static f32 SAngle_to_Degree(s16 angle) { return (360.0f / 65536.0f) * angle; }
68 static f32 SAngle_to_Radian(s16 angle) { return 9.58738E-5f * angle; }
69 static f32 SAngle_to_Normal(s16 angle) { return 3.0517578E-5f * angle; }
70 static s16 Radian_to_SAngle(f32 rad) { return rad * 10430.378f; }
71
72 /* Converts Radian value into Degree value */
73 static f32 r2d(f32 r) { return Radian_to_Degree(r); }
74
75 /* Converts Degree value into Radian value */
76 static f32 d2r(f32 d) { return Degree_to_Radian(d); }
77
78 /* Converts Degree value to s16 angle */
79 static s16 d2s(f32 d) { return Degree_to_SAngle(d); }
80
81 /* Converts s16 angle to Degree value */
82 static f32 s2d(s16 a) { return SAngle_to_Degree(a); }
83
84 template <typename T>
85 static T Adjust(T f1, T f2, T f3);
86};
87
88template <typename T>
89T cAngle::Adjust(T f1, T f2, T f3) {
90 while (f1 >= f3) {
91 f1 -= f3 - f2;
92 }
93 while (f1 < f2) {
94 f1 += f3 - f2;
95 }
96 return f1;
97}
98
99class cDegree {
100private:
101 float mDegree;
102
103public:
104 cDegree(float);
106
107 cDegree& Formal(void);
108 void Val(float);
109 float Radian(void) const;
110 float Sin(void) const;
111 float Cos(void) const;
112 float Tan(void) const;
113
114 operator f32() const { return mDegree; }
115
116 cDegree operator*(float v) const {
117 return cDegree(mDegree * v);
118 }
119};
120
121class cSPolar {
122private:
123 float mRadial;
126
127public:
129 cSPolar(const cXyz&);
130 cSPolar& Formal(void);
131 void Val(float, short, short);
132 void Val(const cXyz&);
133 cXyz Xyz(void) const;
134 void Globe(class cSGlobe*) const;
135
136 void R(f32 i_radial) { mRadial = i_radial; }
137 void U(cSAngle const& i_angle) { mAngle2 = i_angle.Val(); }
138 void V(cSAngle const& i_angle) { mAngle1 = i_angle.Val(); }
139};
140
141class cSGlobe {
142public:
143 float mRadius;
144 cSAngle mInclination; // original: V
145 cSAngle mAzimuth; // original: U
146
147#ifdef __MWERKS__
150 cSGlobe(const cSGlobe&);
151#else
152 cSGlobe() = default;
153 ~cSGlobe() = default;
154 cSGlobe(const cSGlobe&) = default;
155#endif
156
157 void R(f32 i_radius) { mRadius = i_radius; }
158 void U(cSAngle const& i_azimuth) { mAzimuth = i_azimuth.Val(); }
159 void V(cSAngle const& i_inclination) { mInclination = i_inclination.Val(); }
160
161 cSGlobe(float, short, short);
162 cSGlobe(float, const cSAngle&, const cSAngle&);
163 cSGlobe(const cXyz&);
164 cSGlobe& Formal(void);
165 void Val(const cSGlobe&);
166 void Val(float, short, short);
167 void Val(float, const cSAngle&, const cSAngle&);
168 void Val(const cXyz&);
169 float R(void) const { return mRadius; }
170 const cSAngle& V(void) const { return mInclination; }
171 const cSAngle& U(void) const { return mAzimuth; }
172 cXyz Xyz(void) const;
173 void Polar(cSPolar*) const;
174 cXyz Norm(void) const;
175 cSGlobe& Invert(void);
176};
177
178#endif /* C_ANGLE_H */
cSAngle operator-(short, const cSAngle &)
cSAngle operator+(short, const cSAngle &)
Definition c_angle.h:99
float Radian(void) const
Definition c_angle.cpp:132
cDegree(float)
Definition c_angle.cpp:118
cDegree operator*(float v) const
Definition c_angle.h:116
float Tan(void) const
Definition c_angle.cpp:144
float Cos(void) const
Definition c_angle.cpp:140
void Val(float)
Definition c_angle.cpp:127
float Sin(void) const
Definition c_angle.cpp:136
cDegree & Formal(void)
Definition c_angle.cpp:122
~cDegree()
Definition c_angle.h:105
float mDegree
Definition c_angle.h:101
Definition c_angle.h:6
float Norm(void) const
Definition c_angle.cpp:50
bool operator>(const cSAngle &other) const
Definition c_angle.h:50
cSAngle operator+(short) const
float Sin(void) const
Definition c_angle.cpp:62
void mirrorAtMaxNeg(void)
Definition c_angle.h:57
cSAngle operator-(void) const
Definition c_angle.cpp:70
s16 mAngle
Definition c_angle.h:8
bool operator<(const cSAngle &other) const
Definition c_angle.h:49
cSAngle(const cSAngle &)=default
cSAngle operator*(float) const
Definition c_angle.cpp:102
s16 Inv(void) const
Definition c_angle.cpp:58
float Degree(void) const
Definition c_angle.cpp:42
static const cSAngle _180
Definition c_angle.h:14
static const cSAngle _0
Definition c_angle.h:11
static const cSAngle _1
Definition c_angle.h:12
bool operator<=(const cSAngle &other) const
Definition c_angle.h:51
s16 Val() const
Definition c_angle.h:27
cSAngle operator-(short) const
~cSAngle()
Definition c_angle.h:18
float Cos(void) const
Definition c_angle.cpp:66
void operator-=(const cSAngle &)
Definition c_angle.cpp:86
void operator*=(float)
Definition c_angle.cpp:106
cSAngle()
Definition c_angle.h:17
cSAngle operator+(const cSAngle &) const
Definition c_angle.cpp:74
static cSAngle getMaxNegative(void)
Definition c_angle.h:56
void operator+=(short)
cSAngle()=default
static const cSAngle _270
Definition c_angle.h:15
static const cSAngle _90
Definition c_angle.h:13
float Radian(void) const
Definition c_angle.cpp:46
bool operator==(const cSAngle &other) const
Definition c_angle.h:53
bool operator>=(const cSAngle &other) const
Definition c_angle.h:52
void operator=(const cSAngle &other)
Definition c_angle.h:55
~cSAngle()=default
void operator+=(const cSAngle &)
Definition c_angle.cpp:82
s16 Abs(void) const
Definition c_angle.cpp:54
Definition c_angle.h:141
const cSAngle & U(void) const
Definition c_angle.h:171
float R(void) const
Definition c_angle.h:169
cSGlobe(const cSGlobe &)=default
cSAngle mInclination
Definition c_angle.h:144
cSGlobe & Formal(void)
Definition c_angle.cpp:225
cSGlobe(float, short, short)
cXyz Xyz(void) const
Definition c_angle.cpp:267
void R(f32 i_radius)
Definition c_angle.h:157
~cSGlobe()
Definition c_angle.h:149
~cSGlobe()=default
void Polar(cSPolar *) const
Definition c_angle.cpp:273
cSAngle mAzimuth
Definition c_angle.h:145
const cSAngle & V(void) const
Definition c_angle.h:170
float mRadius
Definition c_angle.h:143
cXyz Norm(void) const
Definition c_angle.cpp:277
void V(cSAngle const &i_inclination)
Definition c_angle.h:159
cSGlobe()=default
cSGlobe()
Definition c_angle.h:148
cSGlobe & Invert(void)
Definition c_angle.cpp:282
void Val(float, short, short)
void U(cSAngle const &i_azimuth)
Definition c_angle.h:158
void Val(const cSGlobe &)
Definition c_angle.cpp:240
Definition c_angle.h:121
void R(f32 i_radial)
Definition c_angle.h:136
void U(cSAngle const &i_angle)
Definition c_angle.h:137
cSPolar & Formal(void)
Definition c_angle.cpp:152
cSAngle mAngle2
Definition c_angle.h:125
cSPolar()
Definition c_angle.h:128
cXyz Xyz(void) const
Definition c_angle.cpp:193
void V(cSAngle const &i_angle)
Definition c_angle.h:138
cSAngle mAngle1
Definition c_angle.h:124
void Val(float, short, short)
void Globe(class cSGlobe *) const
Definition c_angle.cpp:203
float mRadial
Definition c_angle.h:123
signed short int s16
Definition types.h:9
float f32
Definition types.h:25
r
Definition e_acos.c:100
double v
Definition e_pow.c:163
a
Definition k_cos.c:89
Definition c_angle.h:63
static s16 Radian_to_SAngle(f32 rad)
Definition c_angle.h:70
static s16 Degree_to_SAngle(f32 deg)
Definition c_angle.h:66
static f32 Radian_to_Degree(f32 rad)
Definition c_angle.h:64
static f32 SAngle_to_Degree(s16 angle)
Definition c_angle.h:67
static f32 r2d(f32 r)
Definition c_angle.h:73
static f32 d2r(f32 d)
Definition c_angle.h:76
static T Adjust(T f1, T f2, T f3)
Definition c_angle.h:89
static f32 SAngle_to_Normal(s16 angle)
Definition c_angle.h:69
static s16 d2s(f32 d)
Definition c_angle.h:79
static f32 SAngle_to_Radian(s16 angle)
Definition c_angle.h:68
static f32 s2d(s16 a)
Definition c_angle.h:82
static f32 Degree_to_Radian(f32 deg)
Definition c_angle.h:65
Definition c_xyz.h:7