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 <dol/mLib/m_angle.hpp>
5
9class mVec2_c {
10public:
11
14
16 mVec2_c(const f32 *p) { x = p[0]; y = p[1]; }
17
19 mVec2_c(f32 fx, f32 fy) { x = fx; y = fy; }
20
22 mVec2_c(const Vec2 &v) { x = v.x; y = v.y; }
23
25 mVec2_c(const nw4r::math::VEC2 &v) { x = v.x; y = v.y; }
26
28 operator f32*() { return &x; }
29
31 operator const f32*() const { return &x; }
32
34 operator Vec2*() { return (Vec2*)&x; }
35
37 operator const Vec2*() const { return (const Vec2*)&x; }
38
40 operator nw4r::math::VEC2*() { return (nw4r::math::VEC2*)&x; }
41
43 operator const nw4r::math::VEC2*() const { return (const nw4r::math::VEC2*)&x; }
44
46 mVec2_c &operator+=(const mVec2_c &v) { x += v.x; y += v.y; return *this; }
47
49 mVec2_c &operator-=(const mVec2_c &v) { x -= v.x; y -= v.y; return *this; }
50
52 mVec2_c &operator*=(f32 f) { x *= f; y *= f; return *this; }
53
55 mVec2_c &operator/=(f32 f) { return operator*=(1.0f / f); }
56
58 mVec2_c operator+() const { return *this; }
59
61 mVec2_c operator-() const { return mVec2_c(-x, -y); }
62
64 mVec2_c operator+(const mVec2_c &v) const { return mVec2_c(x + v.x, y + v.y); }
65
67 mVec2_c operator-(const mVec2_c &v) const { return mVec2_c(x - v.x, y - v.y); }
68
70 mVec2_c operator*(f32 f) const { return mVec2_c(f * x, f * y); }
71
73 mVec2_c operator/(f32 f) const { f32 r = 1.0f / f; return operator*(r); }
74
76 bool operator==(const mVec2_c &v) const { return x == v.x && y == v.y; }
77
79 bool operator!=(const mVec2_c &v) const { return x != v.x || y != v.y; }
80
81 float x;
82 float y;
83};
84
88class mVec3_c {
89public:
90
93
95 mVec3_c(const f32 *p) { x = p[0]; y = p[1]; z = p[2]; }
96
98 mVec3_c(f32 fx, f32 fy, f32 fz) { x = fx; y = fy; z = fz; }
99
101 mVec3_c(const Vec &v) { x = v.x; y = v.y; z = v.z; }
102
104 mVec3_c(const nw4r::math::VEC3 &v) { x = v.x; y = v.y; z = v.z; }
105
107 operator f32*() { return &x; }
108
110 operator const f32*() const { return &x; }
111
113 operator Vec*() { return (Vec*)&x; }
114
116 operator const Vec*() const { return (const Vec*)&x; }
117
119 operator nw4r::math::VEC3*() { return (nw4r::math::VEC3*)&x; }
120
122 operator const nw4r::math::VEC3*() const { return (const nw4r::math::VEC3*)&x; }
123
125 mVec3_c &operator+=(const mVec3_c &v) { x += v.x; y += v.y; z += v.z; return *this; }
126
128 mVec3_c &operator-=(const mVec3_c &v) { x -= v.x; y -= v.y; z -= v.z; return *this; }
129
131 mVec3_c &operator*=(f32 f) { x *= f; y *= f; z *= f; return *this; }
132
134 mVec3_c &operator/=(f32 f) { return operator*=(1.0f / f); }
135
137 mVec3_c operator+() const { return *this; }
138
140 mVec3_c operator-() const { return mVec3_c(-x, -y, -z); }
141
143 mVec3_c operator+(const mVec3_c &v) const { return mVec3_c(x + v.x, y + v.y, z + v.z); }
144
146 mVec3_c operator-(const mVec3_c &v) const { return mVec3_c(x - v.x, y - v.y, z - v.z); }
147
149 mVec3_c operator*(f32 f) const { return mVec3_c(f * x, f * y, f * z); }
150
152 mVec3_c operator/(f32 f) const { f32 r = 1.0f / f; return operator*(r); }
153
155 bool operator==(const mVec3_c &v) const { return x == v.x && y == v.y && z == v.z; }
156
158 bool operator!=(const mVec3_c &v) const { return x != v.x || y != v.y || z != v.z; }
159
162 float normalize();
163
166 bool normalizeRS();
167
168 void rotX(mAng angle);
169 void rotY(mAng angle);
170
171 float x;
172 float y;
173 float z;
174
175 static mVec3_c Zero;
176 static mVec3_c Ex;
177 static mVec3_c Ey;
178 static mVec3_c Ez;
179};
A two-dimensional floating point vector.
Definition m_vec.hpp:9
float y
The coordinates on the Y axis.
Definition m_vec.hpp:82
mVec2_c operator+() const
Positive operator.
Definition m_vec.hpp:58
bool operator!=(const mVec2_c &v) const
Inequality operator.
Definition m_vec.hpp:79
mVec2_c & operator+=(const mVec2_c &v)
Augmented addition operator.
Definition m_vec.hpp:46
mVec2_c operator+(const mVec2_c &v) const
Addition operator.
Definition m_vec.hpp:64
mVec2_c(const nw4r::math::VEC2 &v)
Constructs a new vector from an existing vector from the nw4r::math library.
Definition m_vec.hpp:25
mVec2_c()
Constructs an empty vector.
Definition m_vec.hpp:13
mVec2_c & operator/=(f32 f)
Augmented scalar division operator.
Definition m_vec.hpp:55
mVec2_c(const Vec2 &v)
Constructs a new vector from an existing vector from the MTX library.
Definition m_vec.hpp:22
mVec2_c operator/(f32 f) const
Scalar division operator.
Definition m_vec.hpp:73
bool operator==(const mVec2_c &v) const
Equality operator.
Definition m_vec.hpp:76
mVec2_c(const f32 *p)
Constructs a vector from a float array.
Definition m_vec.hpp:16
mVec2_c(f32 fx, f32 fy)
Constructs a vector from two floating point values.
Definition m_vec.hpp:19
mVec2_c & operator*=(f32 f)
Augmented scalar product operator.
Definition m_vec.hpp:52
mVec2_c operator*(f32 f) const
Scalar product operator.
Definition m_vec.hpp:70
mVec2_c & operator-=(const mVec2_c &v)
Augmented subtraction operator.
Definition m_vec.hpp:49
mVec2_c operator-(const mVec2_c &v) const
Subtraction operator.
Definition m_vec.hpp:67
float x
The coordinates on the X axis.
Definition m_vec.hpp:81
mVec2_c operator-() const
Negative operator.
Definition m_vec.hpp:61
A three-dimensional floating point vector.
Definition m_vec.hpp:88
mVec3_c operator/(f32 f) const
Scalar division operator.
Definition m_vec.hpp:152
static mVec3_c Ex
The unit vector for the X axis.
Definition m_vec.hpp:176
static mVec3_c Ey
The unit vector for the Y axis.
Definition m_vec.hpp:177
mVec3_c(const nw4r::math::VEC3 &v)
Constructs a new vector from an existing vector from the nw4r::math library.
Definition m_vec.hpp:104
mVec3_c & operator-=(const mVec3_c &v)
Augmented subtraction operator.
Definition m_vec.hpp:128
float y
The coordinates on the Y axis.
Definition m_vec.hpp:172
mVec3_c operator*(f32 f) const
Scalar product operator.
Definition m_vec.hpp:149
float x
The coordinates on the X axis.
Definition m_vec.hpp:171
mVec3_c & operator+=(const mVec3_c &v)
Augmented addition operator.
Definition m_vec.hpp:125
bool normalizeRS()
Normalizes the vector.
Definition m_vec.cpp:28
mVec3_c operator-() const
Negative operator.
Definition m_vec.hpp:140
mVec3_c operator-(const mVec3_c &v) const
Subtraction operator.
Definition m_vec.hpp:146
mVec3_c(f32 fx, f32 fy, f32 fz)
Constructs a vector from three floating point values.
Definition m_vec.hpp:98
mVec3_c(const f32 *p)
Constructs a vector from a float array.
Definition m_vec.hpp:95
float normalize()
Normalizes the vector.
Definition m_vec.cpp:19
bool operator==(const mVec3_c &v) const
Equality operator.
Definition m_vec.hpp:155
mVec3_c & operator*=(f32 f)
Augmented scalar product operator.
Definition m_vec.hpp:131
mVec3_c operator+() const
Positive operator.
Definition m_vec.hpp:137
float z
The coordinates on the Z axis.
Definition m_vec.hpp:173
void rotX(mAng angle)
Rotates the vector on the X axis by the given angle.
Definition m_vec.cpp:38
void rotY(mAng angle)
Rotates the vector on the Y axis by the given angle.
Definition m_vec.cpp:47
static mVec3_c Zero
The null vector.
Definition m_vec.hpp:175
mVec3_c & operator/=(f32 f)
Augmented scalar division operator.
Definition m_vec.hpp:134
bool operator!=(const mVec3_c &v) const
Inequality operator.
Definition m_vec.hpp:158
mVec3_c(const Vec &v)
Constructs a new vector from an existing vector from the MTX library.
Definition m_vec.hpp:101
mVec3_c operator+(const mVec3_c &v) const
Addition operator.
Definition m_vec.hpp:143
mVec3_c()
Constructs an empty vector.
Definition m_vec.hpp:92
static mVec3_c Ez
The unit vector for the Z axis.
Definition m_vec.hpp:178
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 two-dimensional floating point vector.
Definition vec.hpp:7
A three-dimensional floating point vector.
Definition vec.hpp:13