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;
18 cSAngle(const cSAngle&);
19 cSAngle(s16);
20 cSAngle(float);
21 s16 Val() const { return this->mAngle; }
22 // void Set(s16 angle) { this->mAngle = angle; }
23 void Val(const cSAngle&);
24 void Val(s16);
25 void Val(float);
26 float Degree(void) const;
27 float Radian(void) const;
28 float Norm(void) const;
29 s16 Abs(void) const;
30 s16 Inv(void) const;
31 float Sin(void) const;
32 float Cos(void) const;
33 cSAngle operator-(void) const;
34 cSAngle operator+(const cSAngle&) const;
35 cSAngle operator-(const cSAngle&) const;
36 void operator+=(const cSAngle&);
37 void operator-=(const cSAngle&);
38 cSAngle operator+(short) const;
39 cSAngle operator-(short) const;
40 void operator+=(short);
41 cSAngle operator*(float) const;
42 void operator*=(float);
43 bool operator<(const cSAngle& other) const { return mAngle < other.mAngle; }
44 bool operator>(const cSAngle& other) const { return mAngle > other.mAngle; }
45 operator s16(void) const { return mAngle; }
46 void operator=(const cSAngle& other) { mAngle = other.mAngle; }
47 static inline cSAngle getMaxNegative(void) { return cSAngle((s16)-0x8000); }
48 inline void mirrorAtMaxNeg(void) { *this = cSAngle((s16)-0x8000) - *this; }
49};
50
51cSAngle operator+(short, const cSAngle&);
52cSAngle operator-(short, const cSAngle&);
53
54struct cAngle {
55 static f32 Radian_to_Degree(f32 rad) { return rad * 57.2957763671875f; }
56 static f32 Degree_to_Radian(f32 deg) { return deg * 0.017453292f; }
57 static s16 Degree_to_SAngle(f32 deg) { return deg * 182.04444885253906f; }
58 static f32 SAngle_to_Degree(s16 angle) { return (360.0f / 65536.0f) * angle; }
59 static f32 SAngle_to_Radian(s16 angle) { return 9.58738E-5f * angle; }
60 static f32 SAngle_to_Normal(s16 angle) { return 3.0517578E-5f * angle; }
61 static s16 Radian_to_SAngle(f32 rad) { return rad * 10430.378f; }
62
63 /* Converts Radian value into Degree value */
64 static f32 r2d(f32 r) { return Radian_to_Degree(r); }
65
66 /* Converts Degree value into Radian value */
67 static f32 d2r(f32 d) { return Degree_to_Radian(d); }
68
69 /* Converts Degree value to s16 angle */
70 static s16 d2s(f32 d) { return Degree_to_SAngle(d); }
71
72 template <typename T>
73 static T Adjust(T f1, T f2, T f3);
74};
75
76template <typename T>
78 while (f1 >= f3) {
79 f1 -= f3 - f2;
80 }
81 while (f1 < f2) {
82 f1 += f3 - f2;
83 }
84 return f1;
85}
86
87class cDegree {
88private:
89 float mDegree;
90
91public:
92 cDegree(float);
94
95 cDegree& Formal(void);
96 void Val(float);
97 float Radian(void) const;
98 float Sin(void) const;
99 float Cos(void) const;
100 float Tan(void) const;
101};
102
103class cSPolar {
104private:
105 float mRadial;
108
109public:
111 cSPolar(const cXyz&);
112 cSPolar& Formal(void);
113 void Val(float, short, short);
114 void Val(const cXyz&);
115 cXyz Xyz(void) const;
116 void Globe(class cSGlobe*) const;
117
119 void U(cSAngle const& i_angle) { mAngle2 = i_angle.Val(); }
120 void V(cSAngle const& i_angle) { mAngle1 = i_angle.Val(); }
121};
122
123class cSGlobe {
124public:
125 float mRadius;
126 cSAngle mInclination; // original: V
127 cSAngle mAzimuth; // original: U
128
130
132 void U(cSAngle const& i_azimuth) { mAzimuth = i_azimuth.Val(); }
133
134 cSGlobe(const cSGlobe&);
135 cSGlobe(float, short, short);
136 cSGlobe(float, const cSAngle&, const cSAngle&);
137 cSGlobe(const cXyz&);
139 cSGlobe& Formal(void);
140 void Val(const cSGlobe&);
141 void Val(float, short, short);
142 void Val(float, const cSAngle&, const cSAngle&);
143 void Val(const cXyz&);
144 float R(void) const { return mRadius; }
145 const cSAngle& V(void) const { return mInclination; }
146 const cSAngle& U(void) const { return mAzimuth; }
147 cXyz Xyz(void) const;
148 void Polar(cSPolar*) const;
149 cXyz Norm(void) const;
150 cSGlobe& Invert(void);
151};
152
153#endif /* C_ANGLE_H */
cSAngle operator-(short, const cSAngle &)
cSAngle operator+(short, const cSAngle &)
T cLib_calcTimer(T *value)
Definition c_lib.h:74
Definition c_angle.h:87
float Radian(void) const
Definition c_angle.cpp:159
float Tan(void) const
Definition c_angle.cpp:174
float Cos(void) const
Definition c_angle.cpp:169
void Val(float)
Definition c_angle.cpp:153
float Sin(void) const
Definition c_angle.cpp:164
cDegree & Formal(void)
Definition c_angle.cpp:147
~cDegree()
Definition c_angle.h:93
float mDegree
Definition c_angle.h:89
Definition c_angle.h:6
float Norm(void) const
Definition c_angle.cpp:57
bool operator>(const cSAngle &other) const
Definition c_angle.h:44
cSAngle operator+(short) const
float Sin(void) const
Definition c_angle.cpp:72
void mirrorAtMaxNeg(void)
Definition c_angle.h:48
cSAngle operator-(void) const
Definition c_angle.cpp:82
s16 mAngle
Definition c_angle.h:8
bool operator<(const cSAngle &other) const
Definition c_angle.h:43
cSAngle operator*(float) const
Definition c_angle.cpp:122
s16 Inv(void) const
Definition c_angle.cpp:67
float Degree(void) const
Definition c_angle.cpp:47
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
s16 Val() const
Definition c_angle.h:21
cSAngle operator-(short) const
~cSAngle()
Definition c_angle.h:17
float Cos(void) const
Definition c_angle.cpp:77
void operator-=(const cSAngle &)
Definition c_angle.cpp:102
void operator*=(float)
Definition c_angle.cpp:127
cSAngle()
Definition c_angle.h:16
cSAngle operator+(const cSAngle &) const
Definition c_angle.cpp:87
static cSAngle getMaxNegative(void)
Definition c_angle.h:47
void operator+=(short)
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:52
void operator=(const cSAngle &other)
Definition c_angle.h:46
void operator+=(const cSAngle &)
Definition c_angle.cpp:97
s16 Abs(void) const
Definition c_angle.cpp:62
Definition c_angle.h:123
const cSAngle & U(void) const
Definition c_angle.h:146
float R(void) const
Definition c_angle.h:144
cSAngle mInclination
Definition c_angle.h:126
cSGlobe & Formal(void)
Definition c_angle.cpp:264
cSGlobe(float, short, short)
cXyz Xyz(void) const
Definition c_angle.cpp:311
void R(f32 i_radius)
Definition c_angle.h:131
~cSGlobe()
Definition c_angle.h:138
void Polar(cSPolar *) const
Definition c_angle.cpp:318
cSAngle mAzimuth
Definition c_angle.h:127
const cSAngle & V(void) const
Definition c_angle.h:145
float mRadius
Definition c_angle.h:125
cXyz Norm(void) const
Definition c_angle.cpp:323
cSGlobe()
Definition c_angle.h:129
cSGlobe & Invert(void)
Definition c_angle.cpp:329
void Val(float, short, short)
void U(cSAngle const &i_azimuth)
Definition c_angle.h:132
void Val(const cSGlobe &)
Definition c_angle.cpp:280
Definition c_angle.h:103
void R(f32 i_radial)
Definition c_angle.h:118
void U(cSAngle const &i_angle)
Definition c_angle.h:119
cSPolar & Formal(void)
Definition c_angle.cpp:184
cSAngle mAngle2
Definition c_angle.h:107
cSPolar()
Definition c_angle.h:110
cXyz Xyz(void) const
Definition c_angle.cpp:228
void V(cSAngle const &i_angle)
Definition c_angle.h:120
cSAngle mAngle1
Definition c_angle.h:106
void Val(float, short, short)
void Globe(class cSGlobe *) const
Definition c_angle.cpp:239
float mRadial
Definition c_angle.h:105
static u8 angle[2+2]
Definition d_a_obj_kago.cpp:845
r
Definition e_acos.c:100
static const double T[]
Definition k_tan.c:106
Definition c_angle.h:54
static s16 Radian_to_SAngle(f32 rad)
Definition c_angle.h:61
static s16 Degree_to_SAngle(f32 deg)
Definition c_angle.h:57
static f32 Radian_to_Degree(f32 rad)
Definition c_angle.h:55
static f32 SAngle_to_Degree(s16 angle)
Definition c_angle.h:58
static f32 r2d(f32 r)
Definition c_angle.h:64
static f32 d2r(f32 d)
Definition c_angle.h:67
static T Adjust(T f1, T f2, T f3)
Definition c_angle.h:77
static f32 SAngle_to_Normal(s16 angle)
Definition c_angle.h:60
static s16 d2s(f32 d)
Definition c_angle.h:70
static f32 SAngle_to_Radian(s16 angle)
Definition c_angle.h:59
static f32 Degree_to_Radian(f32 deg)
Definition c_angle.h:56
Definition d_a_hozelda.cpp:20
float f32
Definition types.h:22
signed short s16
Definition types.h:5