NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
m_vec.hpp
1#pragma once
2#include <lib/nw4r/math/vec.hpp>
3#include <lib/rvl/mtx/vec.h>
4#include <game/mLib/m_angle.hpp>
5#include <lib/egg/math.hpp>
6
9class mVec2_c : public EGG::Vector2f {
10public:
11
14
15 ~mVec2_c() {}
16
18 mVec2_c(const f32 *p) { x = p[0]; y = p[1]; }
19
21 mVec2_c(f32 fx, f32 fy) { set(fx, fy); }
22
24 mVec2_c(const mVec2_c &v) { set(v.x, v.y); }
25
26 void set(float x, float y) {
27 this->x = x;
28 this->y = y;
29 }
30
33 void incX(float x) { this->x += x; }
34
37 void incY(float y) { this->y += y; }
38
39 // mVec2_c &operator=(const mVec2_c &v) { set(v.x, v.y); return *this; }
40 mVec2_c &operator=(const mVec2_c &v) { x = v.x; y = v.y; return *this; }
41
43 operator f32*() { return &x; }
44
46 operator const f32*() const { return &x; }
47
49 operator Vec2*() { return (Vec2*)&x; }
50
52 operator const Vec2*() const { return (const Vec2*)&x; }
53
55 operator nw4r::math::VEC2*() { return (nw4r::math::VEC2*)&x; }
56
58 operator const nw4r::math::VEC2*() const { return (const nw4r::math::VEC2*)&x; }
59
61 mVec2_c &operator+=(const mVec2_c &v) { x += v.x; y += v.y; return *this; }
62
64 mVec2_c &operator-=(const mVec2_c &v) { x -= v.x; y -= v.y; return *this; }
65
67 mVec2_c &operator*=(f32 f) { x *= f; y *= f; return *this; }
68
70 mVec2_c &operator/=(f32 f) { return operator*=(1.0f / f); }
71
73 mVec2_c operator+() const { return *this; }
74
76 mVec2_c operator-() const { return mVec2_c(-x, -y); }
77
79 mVec2_c operator+(const mVec2_c &v) const { return mVec2_c(x + v.x, y + v.y); }
80
82 mVec2_c operator-(const mVec2_c &v) const { return mVec2_c(x - v.x, y - v.y); }
83
85 mVec2_c operator*(f32 f) const { return mVec2_c(f * x, f * y); }
86
88 mVec2_c operator/(f32 f) const { f32 r = 1.0f / f; return operator*(r); }
89
91 bool operator==(const mVec2_c &v) const { return x == v.x && y == v.y; }
92
94 bool operator!=(const mVec2_c &v) const { return x != v.x || y != v.y; }
95};
96
100class mVec3_c : public nw4r::math::VEC3 {
101public:
102
105
107 mVec3_c(const f32 *p) { x = p[0]; y = p[1]; z = p[2]; }
108
110 mVec3_c(f32 fx, f32 fy, f32 fz) { x = fx; y = fy; z = fz; }
111
113 mVec3_c(const Vec &v) { x = v.x; y = v.y; z = v.z; }
114
116 mVec3_c(const nw4r::math::VEC3 &v) { x = v.x; y = v.y; z = v.z; }
117
119 operator f32*() { return &x; }
120
122 operator const f32*() const { return &x; }
123
125 operator Vec*() { return (Vec*)&x; }
126
128 operator const Vec*() const { return (const Vec*)&x; }
129
131 operator nw4r::math::VEC3*() { return (nw4r::math::VEC3*)&x; }
132
134 operator const nw4r::math::VEC3*() const { return (const nw4r::math::VEC3*)&x; }
135
137 mVec3_c &operator+=(const mVec3_c &v) { x += v.x; y += v.y; z += v.z; return *this; }
138
140 mVec3_c &operator-=(const mVec3_c &v) { x -= v.x; y -= v.y; z -= v.z; return *this; }
141
143 mVec3_c &operator*=(f32 f) { x *= f; y *= f; z *= f; return *this; }
144
146 mVec3_c &operator/=(f32 f) { return operator*=(1.0f / f); }
147
149 mVec3_c operator+() const { return *this; }
150
152 mVec3_c operator-() const { return mVec3_c(-x, -y, -z); }
153
155 mVec3_c operator+(const mVec3_c &v) const { return mVec3_c(x + v.x, y + v.y, z + v.z); }
156
158 mVec3_c operator-(const mVec3_c &v) const { return mVec3_c(x - v.x, y - v.y, z - v.z); }
159
161 mVec3_c operator*(f32 f) const { return mVec3_c(f * x, f * y, f * z); }
162
164 mVec3_c operator/(f32 f) const { f32 r = 1.0f / f; return operator*(r); }
165
167 bool operator==(const mVec3_c &v) const { return x == v.x && y == v.y && z == v.z; }
168
170 bool operator!=(const mVec3_c &v) const { return x != v.x || y != v.y || z != v.z; }
171
174 float normalize();
175
178 bool normalizeRS();
179
180 void rotX(mAng angle);
181 void rotY(mAng angle);
182
183 static mVec3_c Zero;
184 static mVec3_c Ex;
185 static mVec3_c Ey;
186 static mVec3_c Ez;
187};
A two-dimensional floating point vector.
Definition math.hpp:26
A two-dimensional floating point vector.
Definition m_vec.hpp:9
mVec2_c(const mVec2_c &v)
Copy constructor.
Definition m_vec.hpp:24
mVec2_c operator+() const
Positive operator.
Definition m_vec.hpp:73
bool operator!=(const mVec2_c &v) const
Inequality operator.
Definition m_vec.hpp:94
mVec2_c & operator+=(const mVec2_c &v)
Augmented addition operator.
Definition m_vec.hpp:61
mVec2_c operator+(const mVec2_c &v) const
Addition operator.
Definition m_vec.hpp:79
mVec2_c()
Constructs an empty vector.
Definition m_vec.hpp:13
mVec2_c & operator/=(f32 f)
Augmented scalar division operator.
Definition m_vec.hpp:70
mVec2_c operator/(f32 f) const
Scalar division operator.
Definition m_vec.hpp:88
bool operator==(const mVec2_c &v) const
Equality operator.
Definition m_vec.hpp:91
mVec2_c(const f32 *p)
Constructs a vector from a float array.
Definition m_vec.hpp:18
void incY(float y)
Increments the Y coordinate.
Definition m_vec.hpp:37
mVec2_c(f32 fx, f32 fy)
Constructs a vector from two floating point values.
Definition m_vec.hpp:21
mVec2_c & operator*=(f32 f)
Augmented scalar product operator.
Definition m_vec.hpp:67
mVec2_c operator*(f32 f) const
Scalar product operator.
Definition m_vec.hpp:85
mVec2_c & operator-=(const mVec2_c &v)
Augmented subtraction operator.
Definition m_vec.hpp:64
mVec2_c operator-(const mVec2_c &v) const
Subtraction operator.
Definition m_vec.hpp:82
mVec2_c operator-() const
Negative operator.
Definition m_vec.hpp:76
void incX(float x)
Increments the X coordinate.
Definition m_vec.hpp:33
A three-dimensional floating point vector.
Definition m_vec.hpp:100
mVec3_c operator/(f32 f) const
Scalar division operator.
Definition m_vec.hpp:164
static mVec3_c Ex
The unit vector for the X axis.
Definition m_vec.hpp:184
static mVec3_c Ey
The unit vector for the Y axis.
Definition m_vec.hpp:185
mVec3_c(const nw4r::math::VEC3 &v)
Constructs a new vector from an existing vector from the nw4r::math library.
Definition m_vec.hpp:116
mVec3_c & operator-=(const mVec3_c &v)
Augmented subtraction operator.
Definition m_vec.hpp:140
mVec3_c operator*(f32 f) const
Scalar product operator.
Definition m_vec.hpp:161
mVec3_c & operator+=(const mVec3_c &v)
Augmented addition operator.
Definition m_vec.hpp:137
bool normalizeRS()
Normalizes the vector.
Definition m_vec.cpp:27
mVec3_c operator-() const
Negative operator.
Definition m_vec.hpp:152
mVec3_c operator-(const mVec3_c &v) const
Subtraction operator.
Definition m_vec.hpp:158
mVec3_c(f32 fx, f32 fy, f32 fz)
Constructs a vector from three floating point values.
Definition m_vec.hpp:110
mVec3_c(const f32 *p)
Constructs a vector from a float array.
Definition m_vec.hpp:107
float normalize()
Normalizes the vector.
Definition m_vec.cpp:18
bool operator==(const mVec3_c &v) const
Equality operator.
Definition m_vec.hpp:167
mVec3_c & operator*=(f32 f)
Augmented scalar product operator.
Definition m_vec.hpp:143
mVec3_c operator+() const
Positive operator.
Definition m_vec.hpp:149
void rotX(mAng angle)
Rotates the vector on the X axis by the given angle.
Definition m_vec.cpp:37
void rotY(mAng angle)
Rotates the vector on the Y axis by the given angle.
Definition m_vec.cpp:46
static mVec3_c Zero
The null vector.
Definition m_vec.hpp:183
mVec3_c & operator/=(f32 f)
Augmented scalar division operator.
Definition m_vec.hpp:146
bool operator!=(const mVec3_c &v) const
Inequality operator.
Definition m_vec.hpp:170
mVec3_c(const Vec &v)
Constructs a new vector from an existing vector from the MTX library.
Definition m_vec.hpp:113
mVec3_c operator+(const mVec3_c &v) const
Addition operator.
Definition m_vec.hpp:155
mVec3_c()
Constructs an empty vector.
Definition m_vec.hpp:104
static mVec3_c Ez
The unit vector for the Z axis.
Definition m_vec.hpp:186
A two-dimensional floating point vector.
Definition vec.h:13
A three-dimensional floating point vector.
Definition vec.h:18
A one-dimensional short angle vector.
Definition m_angle.hpp:8
A three-dimensional floating point vector.
Definition vec.hpp:22