NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
m_vec.cpp
1#include <game/mLib/m_angle.hpp>
2#include <game/mLib/m_vec.hpp>
3#include <float.h>
4#include <nw4r/math.h>
5
6// [This is required to ensure correct sdata2 ordering]
7// [It will be deadstripped by the linker later]
8DECL_WEAK
9void DUMMY_ORDERING() {
10 nw4r::math::SinIdx(0);
11}
12
13inline bool isZero(float val) {
14 return (std::fabs(val) <= FLT_EPSILON);
15}
16
18 float mag = PSVECMag(*this);
19 if (!isZero(mag)) {
20 operator*=(1.0f/mag);
21 }
22
23 return mag;
24}
25
27 float mag = PSVECMag(*this);
28 if (isZero(mag)) {
29 return false;
30 }
31
32 operator*=(1.0f/mag);
33 return true;
34}
35
36void mVec3_c::rotX(mAng angle) {
37 float cos = angle.cos();
38 float sin = angle.sin();
39 float y = this->y;
40 float z = this->z;
41 this->y = cos * y - sin * z;
42 this->z = sin * y + cos * z;
43}
44
45void mVec3_c::rotY(mAng angle) {
46 float cos = angle.cos();
47 float sin = angle.sin();
48 float x = this->x;
49 float z = this->z;
50 this->x = cos * x + sin * z;
51 this->z = -sin * x + cos * z;
52}
53
54mVec3_c mVec3_c::Zero(0.0f, 0.0f, 0.0f);
55mVec3_c mVec3_c::Ex(1.0f, 0.0f, 0.0f);
56mVec3_c mVec3_c::Ey(0.0f, 1.0f, 0.0f);
57mVec3_c mVec3_c::Ez(0.0f, 0.0f, 1.0f);
A three-dimensional floating point vector.
Definition m_vec.hpp:100
static mVec3_c Ex
The unit vector for the X axis.
Definition m_vec.hpp:209
static mVec3_c Ey
The unit vector for the Y axis.
Definition m_vec.hpp:210
bool normalizeRS()
Normalizes the vector.
Definition m_vec.cpp:26
float normalize()
Normalizes the vector.
Definition m_vec.cpp:17
mVec3_c & operator*=(f32 f)
Augmented scalar product operator.
Definition m_vec.hpp:156
void rotX(mAng angle)
Rotates the vector on the X axis by the given angle.
Definition m_vec.cpp:36
void rotY(mAng angle)
Rotates the vector on the Y axis by the given angle.
Definition m_vec.cpp:45
static mVec3_c Zero
The null vector.
Definition m_vec.hpp:208
static mVec3_c Ez
The unit vector for the Z axis.
Definition m_vec.hpp:211
A one-dimensional short angle vector.
Definition m_angle.hpp:12
float cos() const
Computes the cosine of the angle.
Definition m_angle.hpp:52
float sin() const
Computes the sine of the angle.
Definition m_angle.hpp:49