Loading [MathJax]/extensions/tex2jax.js
Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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.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); }
62 cXyz* operator+=(const Vec& other) {
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 zero() { set(0.0f, 0.0f, 0.0f); }
101
102 f32 getSquareMag() const { return VECSquareMag(this); }
103 f32 getSquareDistance(const Vec& other) const { return VECSquareDistance(this, &other); }
104
105 static f32 getNearZeroValue() { return 8e-11f; }
106
107 bool isNearZeroSquare() const { return (this->getSquareMag() < getNearZeroValue()); }
108 bool isNearZeroSquare(const cXyz& other) const { return (PSVECSquareMag(&other) < getNearZeroValue()); }
109
110 f32 abs2() const { return this->getSquareMag(); }
111 f32 abs2(const Vec& other) const { return this->getSquareDistance(other); }
112 f32 abs2XZ() const {
113 cXyz tmp(this->x, 0, this->z);
114 return tmp.abs2();
115 }
116 f32 abs2XZ(const Vec& other) const {
117 cXyz tmp(this->x, 0, this->z);
118 cXyz tmp2(other.x, 0, other.z);
119 return tmp.abs2(tmp2);
120 }
121
122 f32 abs() const { return sqrtf(this->abs2()); }
123 f32 abs(const Vec& other) const { return sqrtf(this->abs2(other)); }
124 f32 absXZ() const { return sqrtf(this->abs2XZ()); }
125 f32 absXZ(const Vec& other) const { return sqrtf(this->abs2XZ(other)); }
126
127 f32 getMagXZ() const { return cXyz(this->x, 0, this->z).getSquareMag(); }
128
129 f32 getDotProduct(const Vec& other) const { return PSVECDotProduct(this, &other); }
130
131 f32 inprod(const Vec& other) const { return getDotProduct(other); }
132 f32 inprodXZ(const Vec& other) const { return x * other.x + z * other.z; }
133};
134
135#endif /* C_XYZ_H */
void PSVECSquareMag()
float sqrtf(float mag)
Definition math.h:66
Definition d_a_hozelda.cpp:18
f32 z
Definition mtx.h:11
f32 x
Definition mtx.h:11
f32 y
Definition mtx.h:11
Definition d_a_hozelda.cpp:20
f32 inprodXZ(const Vec &other) const
Definition c_xyz.h:132
cXyz normalize()
Definition c_xyz.cpp:98
f32 abs2XZ(const Vec &other) const
Definition c_xyz.h:116
cXyz operator+(Vec const &) const
Definition c_xyz.cpp:11
cXyz(f32 x, f32 y, f32 z)
Definition c_xyz.h:18
bool normalizeRS()
Definition c_xyz.cpp:115
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:111
bool isNearZeroSquare() const
Definition c_xyz.h:107
f32 getSquareDistance(const Vec &other) const
Definition c_xyz.h:103
static const cXyz BaseYZ
Definition c_xyz.h:14
s16 atan2sY_XZ() const
cXyz operator*(f32) const
Definition c_xyz.cpp:25
cXyz()
Definition c_xyz.h:17
static const cXyz BaseXZ
Definition c_xyz.h:13
static const cXyz BaseY
Definition c_xyz.h:10
cXyz outprod(Vec const &) const
Definition c_xyz.cpp:55
bool isNearZeroSquare(const cXyz &other) const
Definition c_xyz.h:108
f32 getDotProduct(const Vec &other) const
Definition c_xyz.h:129
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:79
static const cXyz BaseZ
Definition c_xyz.h:11
bool operator==(Vec const &) const
Definition c_xyz.cpp:125
static const cXyz BaseXYZ
Definition c_xyz.h:15
static f32 getNearZeroValue()
Definition c_xyz.h:105
f32 abs(const Vec &other) const
Definition c_xyz.h:123
cXyz(const Vec &vec)
Definition c_xyz.h:28
~cXyz()
Definition c_xyz.h:16
void operator/=(f32 scale)
Definition c_xyz.h:67
cXyz operator/(f32) const
Definition c_xyz.cpp:41
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:112
cXyz getCrossProduct(Vec const &) const
Definition c_xyz.cpp:48
f32 getXDiff(const Vec *other) const
Definition c_xyz.h:94
void zero()
Definition c_xyz.h:100
cXyz normalizeZP()
Definition c_xyz.cpp:105
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:122
void operator-=(f32 f)
Definition c_xyz.h:49
f32 getSquareMag() const
Definition c_xyz.h:102
f32 absXZ() const
Definition c_xyz.h:124
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:68
bool operator!=(Vec const &) const
Definition c_xyz.cpp:130
bool isZero() const
Definition c_xyz.cpp:135
f32 getMagXZ() const
Definition c_xyz.h:127
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:60
f32 abs2() const
Definition c_xyz.h:110
f32 inprod(const Vec &other) const
Definition c_xyz.h:131
f32 absXZ(const Vec &other) const
Definition c_xyz.h:125
signed short int s16
Definition types.h:6
float f32
Definition types.h:22
asm f32 PSVECDotProduct(const register Vec *a, const register Vec *b)
Definition vec.c:181