NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
m_vec.cpp
1#include <utility_inlines.hpp>
2#include <dol/mLib/m_angle.hpp>
3#include <dol/mLib/m_vec.hpp>
4#include <lib/MSL_C/float.h>
5#include <lib/MSL_C/math.h>
7#include <lib/rvl/mtx/vec.h>
8
9// [This is required to ensure correct sdata2 ordering]
10// [It will be deadstripped by the linker later]
11float DUMMY_M_VEC(s16 val) {
12 return nw4r::math::CosS(val);
13}
14
15inline bool isZero(float val) {
16 return (fabsf(val) <= FLT_EPSILON);
17}
18
20 float mag = PSVECMag(*this);
21 if (!isZero(mag)) {
22 operator*=(1.0f/mag);
23 }
24
25 return mag;
26}
27
29 float mag = PSVECMag(*this);
30 if (isZero(mag)) {
31 return false;
32 }
33
34 operator*=(1.0f/mag);
35 return true;
36}
37
38void mVec3_c::rotX(mAng angle) {
39 float cos = angle.cos();
40 float sin = angle.sin();
41 float y = this->y;
42 float z = this->z;
43 this->y = cos * y - sin * z;
44 this->z = sin * y + cos * z;
45}
46
47void mVec3_c::rotY(mAng angle) {
48 float cos = angle.cos();
49 float sin = angle.sin();
50 float x = this->x;
51 float z = this->z;
52 this->x = cos * x + sin * z;
53 this->z = -sin * x + cos * z;
54}
55
56mVec3_c mVec3_c::Zero = mVec3_c(0.0f, 0.0f, 0.0f);
57mVec3_c mVec3_c::Ex = mVec3_c(1.0f, 0.0f, 0.0f);
58mVec3_c mVec3_c::Ey = mVec3_c(0.0f, 1.0f, 0.0f);
59mVec3_c mVec3_c::Ez = mVec3_c(0.0f, 0.0f, 1.0f);
A three-dimensional floating point vector.
Definition m_vec.hpp:88
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
float y
The coordinates on the Y axis.
Definition m_vec.hpp:172
float x
The coordinates on the X axis.
Definition m_vec.hpp:171
bool normalizeRS()
Normalizes the vector.
Definition m_vec.cpp:28
float normalize()
Normalizes the vector.
Definition m_vec.cpp:19
mVec3_c & operator*=(f32 f)
Augmented scalar product operator.
Definition m_vec.hpp:131
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
static mVec3_c Ez
The unit vector for the Z axis.
Definition m_vec.hpp:178
f32 PSVECMag(const Vec *v)
Computes the magnitude of a vector.
float fabsf(float x)
Returns the absolute value of x.
Definition math.h:20
#define FLT_EPSILON
Difference between 1 and the smallest 32-bit floating-point value greater than 1.
Definition float.h:12
float CosS(short ang)
Computes the cosine value.
A one-dimensional short angle vector.
Definition m_angle.hpp:8
float cos() const
Computes the cosine of the angle.
Definition m_angle.hpp:53
float sin() const
Computes the sine of the angle.
Definition m_angle.hpp:50