Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
c_xyz.h
Go to the documentation of this file.
1#ifndef C_XYZ_H
2#define C_XYZ_H
3
4#include "dolphin/mtx/vec.h"
5#include "math.h"
6
7struct cXyz : Vec {
8 static const cXyz Zero;
9 static const cXyz BaseX;
10 static const cXyz BaseY;
11 static const cXyz BaseZ;
12 static const cXyz BaseXY;
13 static const cXyz BaseXZ;
14 static const cXyz BaseYZ;
15 static const cXyz BaseXYZ;
16 /* 80009184 */ ~cXyz() {}
17 /* inlined */ cXyz() {}
19 this->x = x;
20 this->y = y;
21 this->z = z;
22 }
23 cXyz(const cXyz& vec) {
24 this->x = vec.x;
25 this->y = vec.y;
26 this->z = vec.z;
27 }
28 cXyz(const Vec& vec) {
29 this->x = vec.x;
30 this->y = vec.y;
31 this->z = vec.z;
32 }
33 void operator=(const Vec& vec) {
34 this->x = vec.x;
35 this->y = vec.y;
36 this->z = vec.z;
37 }
38 /* 80266AE4 */ cXyz operator+(Vec const&) const;
39 /* 80266B34 */ cXyz operator-(Vec const&) const;
40 /* 80266B84 */ cXyz operator*(f32) const;
41 /* 80266BD0 */ cXyz operator*(Vec const&) const;
42 /* 80266C18 */ cXyz operator/(f32) const;
43
44 void operator+=(f32 f) {
45 x += f;
46 y += f;
47 z += f;
48 }
49 void operator-=(f32 f) {
50 x -= f;
51 y -= f;
52 z -= f;
53 }
54
55 void operator*=(const Vec& other) {
56 x *= other.x;
57 y *= other.y;
58 z *= other.z;
59 }
60
61 void operator-=(const Vec& other) { VECSubtract(this, &other, this); }
63 VECAdd(this, &other, this);
64 return this;
65 }
66 void operator*=(f32 scale) { VECScale(this, this, scale); }
67 void operator/=(f32 scale) { VECScale(this, this, 1.0f / scale); }
68 /* 80266C6C */ cXyz getCrossProduct(Vec const&) const;
69 /* 80266CBC */ cXyz outprod(Vec const&) const;
70 /* 80266CE4 */ cXyz norm() const;
71 /* 80266D30 */ cXyz normZP() const;
72 /* 80266DC4 */ cXyz normZC() const;
73 /* 80266EF4 */ cXyz normalize();
74 /* 80266F48 */ cXyz normalizeZP();
75 /* 80266FDC */ bool normalizeRS();
76 /* 8026702C */ bool operator==(Vec const&) const;
77 /* 8026706C */ bool operator!=(Vec const&) const;
78 /* 802670AC */ bool isZero() const;
79 /* 80267128 */ s16 atan2sX_Z() const;
80 /* 80267150 */ s16 atan2sY_XZ() const;
81
82 void set(f32 pX, f32 pY, f32 pZ) {
83 x = pX;
84 y = pY;
85 z = pZ;
86 }
87
88 void set(const Vec& other) {
89 x = other.x;
90 y = other.y;
91 z = other.z;
92 }
93
94 f32 getXDiff(const Vec* other) const { return x - other->x; }
95 f32 getYDiff(const Vec* other) const { return y - other->y; }
96 f32 getZDiff(const Vec* other) const { return z - other->z; }
97
98 void setall(f32 f) { set(f, f, f); }
99
100 void setMin(const cXyz& other) {
101 if (x > other.x) {
102 x = other.x;
103 }
104 if (y > other.y) {
105 y = other.y;
106 }
107 if (z > other.z) {
108 z = other.z;
109 }
110 }
111
112 void setMax(const cXyz& other) {
113 if (x < other.x) {
114 x = other.x;
115 }
116 if (y < other.y) {
117 y = other.y;
118 }
119 if (z < other.z) {
120 z = other.z;
121 }
122 }
123 void zero() { set(0.0f, 0.0f, 0.0f); }
124
125 float getSquareMag() const { return VECSquareMag(this); }
126 f32 getSquareDistance(const Vec& other) const { return VECSquareDistance(this, &other); }
127
128 static float getNearZeroValue() { return 8e-11f; }
129
130 bool isNearZeroSquare() const { return (this->getSquareMag() < getNearZeroValue()); }
131 f32 abs2() const { return this->getSquareMag(); }
132 f32 abs2(const Vec& other) const { return this->getSquareDistance(other); }
133 f32 abs2XZ() const {
134 cXyz tmp(this->x, 0, this->z);
135 return tmp.abs2();
136 }
137 f32 abs2XZ(const Vec& other) const {
138 cXyz tmp(this->x, 0, this->z);
139 cXyz tmp2(other.x, 0, other.z);
140 return tmp.abs2(tmp2);
141 }
142 f32 abs() const { return sqrtf(this->abs2()); }
143 f32 abs(const Vec& other) const { return sqrtf(this->abs2(other)); }
144 f32 absXZ() const { return sqrtf(this->abs2XZ()); }
145 f32 absXZ(const Vec& other) const { return sqrtf(this->abs2XZ(other)); }
146 f32 getMagXZ() const { return cXyz(this->x, 0, this->z).getSquareMag(); }
147
148 f32 getDotProduct(const Vec& other) const { return VECDotProduct(this, &other); }
149 f32 inprod(const Vec& other) const { return getDotProduct(other); }
150 f32 inprodXZ(const Vec& other) const { return x * other.x + z * other.z; }
151};
152
153#endif /* C_XYZ_H */
T cLib_calcTimer(T *value)
Definition c_lib.h:74
static char * tmp[5]
Definition d_a_npc_ashB.cpp:231
float sqrtf(float mag)
Definition math.h:62
Definition d_a_hozelda.cpp:18
f32 z
Definition vec.h:11
f32 x
Definition vec.h:11
f32 y
Definition vec.h:11
Definition d_a_hozelda.cpp:20
f32 inprodXZ(const Vec &other) const
Definition c_xyz.h:150
cXyz normalize()
Definition c_xyz.cpp:100
f32 abs2XZ(const Vec &other) const
Definition c_xyz.h:137
cXyz operator+(Vec const &) const
cXyz(f32 x, f32 y, f32 z)
Definition c_xyz.h:18
bool normalizeRS()
Definition c_xyz.cpp:116
void operator-=(const Vec &other)
Definition c_xyz.h:61
void operator*=(f32 scale)
Definition c_xyz.h:66
f32 abs2(const Vec &other) const
Definition c_xyz.h:132
bool isNearZeroSquare() const
Definition c_xyz.h:130
f32 getSquareDistance(const Vec &other) const
Definition c_xyz.h:126
static const cXyz BaseYZ
Definition c_xyz.h:14
s16 atan2sY_XZ() const
cXyz operator*(f32) const
cXyz()
Definition c_xyz.h:17
static const cXyz BaseXZ
Definition c_xyz.h:13
static const cXyz BaseY
Definition c_xyz.h:10
static float getNearZeroValue()
Definition c_xyz.h:128
void setMin(const cXyz &other)
Definition c_xyz.h:100
cXyz outprod(Vec const &) const
Definition c_xyz.cpp:54
f32 getDotProduct(const Vec &other) const
Definition c_xyz.h:148
cXyz(const cXyz &vec)
Definition c_xyz.h:23
void operator=(const Vec &vec)
Definition c_xyz.h:33
void operator*=(const Vec &other)
Definition c_xyz.h:55
cXyz normZC() const
Definition c_xyz.cpp:88
static const cXyz BaseZ
Definition c_xyz.h:11
bool operator==(Vec const &) const
Definition c_xyz.cpp:126
static const cXyz BaseXYZ
Definition c_xyz.h:15
f32 abs(const Vec &other) const
Definition c_xyz.h:143
cXyz(const Vec &vec)
Definition c_xyz.h:28
~cXyz()
Definition c_xyz.h:16
float getSquareMag() const
Definition c_xyz.h:125
void operator/=(f32 scale)
Definition c_xyz.h:67
cXyz operator/(f32) const
Definition c_xyz.cpp:40
void set(f32 pX, f32 pY, f32 pZ)
Definition c_xyz.h:82
cXyz * operator+=(const Vec &other)
Definition c_xyz.h:62
f32 abs2XZ() const
Definition c_xyz.h:133
cXyz getCrossProduct(Vec const &) const
Definition c_xyz.cpp:47
f32 getXDiff(const Vec *other) const
Definition c_xyz.h:94
void zero()
Definition c_xyz.h:123
cXyz normalizeZP()
Definition c_xyz.cpp:106
void setMax(const cXyz &other)
Definition c_xyz.h:112
f32 getYDiff(const Vec *other) const
Definition c_xyz.h:95
void setall(f32 f)
Definition c_xyz.h:98
void set(const Vec &other)
Definition c_xyz.h:88
s16 atan2sX_Z() const
f32 abs() const
Definition c_xyz.h:142
void operator-=(f32 f)
Definition c_xyz.h:49
f32 absXZ() const
Definition c_xyz.h:144
f32 getZDiff(const Vec *other) const
Definition c_xyz.h:96
static const cXyz BaseX
Definition c_xyz.h:9
cXyz normZP() const
Definition c_xyz.cpp:66
bool operator!=(Vec const &) const
Definition c_xyz.cpp:131
bool isZero() const
Definition c_xyz.cpp:136
f32 getMagXZ() const
Definition c_xyz.h:146
cXyz operator-(Vec const &) const
void operator+=(f32 f)
Definition c_xyz.h:44
static const cXyz BaseXY
Definition c_xyz.h:12
static const cXyz Zero
Definition c_xyz.h:8
cXyz norm() const
Definition c_xyz.cpp:59
f32 abs2() const
Definition c_xyz.h:131
f32 inprod(const Vec &other) const
Definition c_xyz.h:149
f32 absXZ(const Vec &other) const
Definition c_xyz.h:145
float f32
Definition types.h:22
signed short s16
Definition types.h:5