Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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 bool operator<=(const cSAngle& other) const { return mAngle <= other.mAngle; }
46 bool operator>=(const cSAngle& other) const { return mAngle >= other.mAngle; }
47 operator s16(void) const { return mAngle; }
48 void operator=(const cSAngle& other) { mAngle = other.mAngle; }
49 static inline cSAngle getMaxNegative(void) { return cSAngle((s16)-0x8000); }
50 inline void mirrorAtMaxNeg(void) { *this = cSAngle((s16)-0x8000) - *this; }
51};
52
53cSAngle operator+(short, const cSAngle&);
54cSAngle operator-(short, const cSAngle&);
55
56struct cAngle {
57 static f32 Radian_to_Degree(f32 rad) { return rad * 57.2957763671875f; }
58 static f32 Degree_to_Radian(f32 deg) { return deg * 0.017453292f; }
59 static s16 Degree_to_SAngle(f32 deg) { return deg * 182.04444885253906f; }
60 static f32 SAngle_to_Degree(s16 angle) { return (360.0f / 65536.0f) * angle; }
61 static f32 SAngle_to_Radian(s16 angle) { return 9.58738E-5f * angle; }
62 static f32 SAngle_to_Normal(s16 angle) { return 3.0517578E-5f * angle; }
63 static s16 Radian_to_SAngle(f32 rad) { return rad * 10430.378f; }
64
65 /* Converts Radian value into Degree value */
66 static f32 r2d(f32 r) { return Radian_to_Degree(r); }
67
68 /* Converts Degree value into Radian value */
69 static f32 d2r(f32 d) { return Degree_to_Radian(d); }
70
71 /* Converts Degree value to s16 angle */
72 static s16 d2s(f32 d) { return Degree_to_SAngle(d); }
73
74 /* Converts s16 angle to Degree value */
75 static f32 s2d(s16 a) { return SAngle_to_Degree(a); }
76
77 template <typename T>
78 static T Adjust(T f1, T f2, T f3);
79};
80
81template <typename T>
82T cAngle::Adjust(T f1, T f2, T f3) {
83 while (f1 >= f3) {
84 f1 -= f3 - f2;
85 }
86 while (f1 < f2) {
87 f1 += f3 - f2;
88 }
89 return f1;
90}
91
92class cDegree {
93private:
94 float mDegree;
95
96public:
97 cDegree(float);
99
100 cDegree& Formal(void);
101 void Val(float);
102 float Radian(void) const;
103 float Sin(void) const;
104 float Cos(void) const;
105 float Tan(void) const;
106};
107
108class cSPolar {
109private:
110 float mRadial;
113
114public:
116 cSPolar(const cXyz&);
117 cSPolar& Formal(void);
118 void Val(float, short, short);
119 void Val(const cXyz&);
120 cXyz Xyz(void) const;
121 void Globe(class cSGlobe*) const;
122
123 void R(f32 i_radial) { mRadial = i_radial; }
124 void U(cSAngle const& i_angle) { mAngle2 = i_angle.Val(); }
125 void V(cSAngle const& i_angle) { mAngle1 = i_angle.Val(); }
126};
127
128class cSGlobe {
129public:
130 float mRadius;
131 cSAngle mInclination; // original: V
132 cSAngle mAzimuth; // original: U
133
135
136 void R(f32 i_radius) { mRadius = i_radius; }
137 void U(cSAngle const& i_azimuth) { mAzimuth = i_azimuth.Val(); }
138 void V(cSAngle const& i_inclination) { mInclination = i_inclination.Val(); }
139
140 cSGlobe(const cSGlobe&);
141 cSGlobe(float, short, short);
142 cSGlobe(float, const cSAngle&, const cSAngle&);
143 cSGlobe(const cXyz&);
145 cSGlobe& Formal(void);
146 void Val(const cSGlobe&);
147 void Val(float, short, short);
148 void Val(float, const cSAngle&, const cSAngle&);
149 void Val(const cXyz&);
150 float R(void) const { return mRadius; }
151 const cSAngle& V(void) const { return mInclination; }
152 const cSAngle& U(void) const { return mAzimuth; }
153 cXyz Xyz(void) const;
154 void Polar(cSPolar*) const;
155 cXyz Norm(void) const;
156 cSGlobe& Invert(void);
157};
158
159#endif /* C_ANGLE_H */
cSAngle operator-(short, const cSAngle &)
cSAngle operator+(short, const cSAngle &)
Definition c_angle.h:92
float Radian(void) const
Definition c_angle.cpp:159
cDegree(float)
Definition c_angle.cpp:142
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:98
float mDegree
Definition c_angle.h:94
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:50
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
bool operator<=(const cSAngle &other) const
Definition c_angle.h:45
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:49
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
bool operator>=(const cSAngle &other) const
Definition c_angle.h:46
void operator=(const cSAngle &other)
Definition c_angle.h:48
void operator+=(const cSAngle &)
Definition c_angle.cpp:97
s16 Abs(void) const
Definition c_angle.cpp:62
Definition c_angle.h:128
const cSAngle & U(void) const
Definition c_angle.h:152
float R(void) const
Definition c_angle.h:150
cSAngle mInclination
Definition c_angle.h:131
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:136
~cSGlobe()
Definition c_angle.h:144
void Polar(cSPolar *) const
Definition c_angle.cpp:318
cSAngle mAzimuth
Definition c_angle.h:132
const cSAngle & V(void) const
Definition c_angle.h:151
float mRadius
Definition c_angle.h:130
cXyz Norm(void) const
Definition c_angle.cpp:323
void V(cSAngle const &i_inclination)
Definition c_angle.h:138
cSGlobe()
Definition c_angle.h:134
cSGlobe & Invert(void)
Definition c_angle.cpp:329
void Val(float, short, short)
void U(cSAngle const &i_azimuth)
Definition c_angle.h:137
void Val(const cSGlobe &)
Definition c_angle.cpp:280
Definition c_angle.h:108
void R(f32 i_radial)
Definition c_angle.h:123
void U(cSAngle const &i_angle)
Definition c_angle.h:124
cSPolar & Formal(void)
Definition c_angle.cpp:184
cSAngle mAngle2
Definition c_angle.h:112
cSPolar()
Definition c_angle.h:115
cXyz Xyz(void) const
Definition c_angle.cpp:228
void V(cSAngle const &i_angle)
Definition c_angle.h:125
cSAngle mAngle1
Definition c_angle.h:111
void Val(float, short, short)
void Globe(class cSGlobe *) const
Definition c_angle.cpp:239
float mRadial
Definition c_angle.h:110
static u8 angle[2+2]
Definition d_a_obj_kago.cpp:845
r
Definition e_acos.c:100
a
Definition k_cos.c:89
Definition c_angle.h:56
static s16 Radian_to_SAngle(f32 rad)
Definition c_angle.h:63
static s16 Degree_to_SAngle(f32 deg)
Definition c_angle.h:59
static f32 Radian_to_Degree(f32 rad)
Definition c_angle.h:57
static f32 SAngle_to_Degree(s16 angle)
Definition c_angle.h:60
static f32 r2d(f32 r)
Definition c_angle.h:66
static f32 d2r(f32 d)
Definition c_angle.h:69
static T Adjust(T f1, T f2, T f3)
Definition c_angle.h:82
static f32 SAngle_to_Normal(s16 angle)
Definition c_angle.h:62
static s16 d2s(f32 d)
Definition c_angle.h:72
static f32 SAngle_to_Radian(s16 angle)
Definition c_angle.h:61
static f32 s2d(s16 a)
Definition c_angle.h:75
static f32 Degree_to_Radian(f32 deg)
Definition c_angle.h:58
Definition d_a_hozelda.cpp:20
signed short int s16
Definition types.h:6
float f32
Definition types.h:22