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 /* Converts s16 angle to Degree value */
73 static f32 s2d(s16 a) { return SAngle_to_Degree(a); }
74
75 template <typename T>
76 static T Adjust(T f1, T f2, T f3);
77};
78
79template <typename T>
81 while (f1 >= f3) {
82 f1 -= f3 - f2;
83 }
84 while (f1 < f2) {
85 f1 += f3 - f2;
86 }
87 return f1;
88}
89
90class cDegree {
91private:
92 float mDegree;
93
94public:
95 cDegree(float);
97
98 cDegree& Formal(void);
99 void Val(float);
100 float Radian(void) const;
101 float Sin(void) const;
102 float Cos(void) const;
103 float Tan(void) const;
104};
105
106class cSPolar {
107private:
108 float mRadial;
111
112public:
114 cSPolar(const cXyz&);
115 cSPolar& Formal(void);
116 void Val(float, short, short);
117 void Val(const cXyz&);
118 cXyz Xyz(void) const;
119 void Globe(class cSGlobe*) const;
120
122 void U(cSAngle const& i_angle) { mAngle2 = i_angle.Val(); }
123 void V(cSAngle const& i_angle) { mAngle1 = i_angle.Val(); }
124};
125
126class cSGlobe {
127public:
128 float mRadius;
129 cSAngle mInclination; // original: V
130 cSAngle mAzimuth; // original: U
131
133
135 void U(cSAngle const& i_azimuth) { mAzimuth = i_azimuth.Val(); }
136
137 cSGlobe(const cSGlobe&);
138 cSGlobe(float, short, short);
139 cSGlobe(float, const cSAngle&, const cSAngle&);
140 cSGlobe(const cXyz&);
142 cSGlobe& Formal(void);
143 void Val(const cSGlobe&);
144 void Val(float, short, short);
145 void Val(float, const cSAngle&, const cSAngle&);
146 void Val(const cXyz&);
147 float R(void) const { return mRadius; }
148 const cSAngle& V(void) const { return mInclination; }
149 const cSAngle& U(void) const { return mAzimuth; }
150 cXyz Xyz(void) const;
151 void Polar(cSPolar*) const;
152 cXyz Norm(void) const;
153 cSGlobe& Invert(void);
154};
155
156#endif /* C_ANGLE_H */
cSAngle operator-(short, const cSAngle &)
cSAngle operator+(short, const cSAngle &)
T cLib_calcTimer(T *value)
Definition c_lib.h:79
Definition c_angle.h:90
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:96
float mDegree
Definition c_angle.h:92
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:126
const cSAngle & U(void) const
Definition c_angle.h:149
float R(void) const
Definition c_angle.h:147
cSAngle mInclination
Definition c_angle.h:129
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:134
~cSGlobe()
Definition c_angle.h:141
void Polar(cSPolar *) const
Definition c_angle.cpp:318
cSAngle mAzimuth
Definition c_angle.h:130
const cSAngle & V(void) const
Definition c_angle.h:148
float mRadius
Definition c_angle.h:128
cXyz Norm(void) const
Definition c_angle.cpp:323
cSGlobe()
Definition c_angle.h:132
cSGlobe & Invert(void)
Definition c_angle.cpp:329
void Val(float, short, short)
void U(cSAngle const &i_azimuth)
Definition c_angle.h:135
void Val(const cSGlobe &)
Definition c_angle.cpp:280
Definition c_angle.h:106
void R(f32 i_radial)
Definition c_angle.h:121
void U(cSAngle const &i_angle)
Definition c_angle.h:122
cSPolar & Formal(void)
Definition c_angle.cpp:184
cSAngle mAngle2
Definition c_angle.h:110
cSPolar()
Definition c_angle.h:113
cXyz Xyz(void) const
Definition c_angle.cpp:228
void V(cSAngle const &i_angle)
Definition c_angle.h:123
cSAngle mAngle1
Definition c_angle.h:109
void Val(float, short, short)
void Globe(class cSGlobe *) const
Definition c_angle.cpp:239
float mRadial
Definition c_angle.h:108
static u8 angle[2+2]
Definition d_a_obj_kago.cpp:845
r
Definition e_acos.c:100
a
Definition k_cos.c:89
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:80
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 s2d(s16 a)
Definition c_angle.h:73
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