NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
m_angle.hpp
1#pragma once
2#include <types.h>
4#include <lib/rvl/mtx/vec.h>
5
8struct mAng {
9
11 mAng() {}
12
14 mAng(const s16 *p) { mAngle = *p; }
15
17 mAng(s16 x) { mAngle = x; }
18
20 operator s16*() { return &mAngle; }
21
23 operator const s16*() const { return &mAngle; }
24
26 mAng &operator+=(const mAng &v) { mAngle += v.mAngle; return *this; }
27
29 mAng &operator-=(const mAng &v) { mAngle -= v.mAngle; return *this; }
30
32 mAng operator+() const { return *this; }
33
35 mAng operator-() const { return mAng(-mAngle); }
36
38 mAng operator+(const mAng &v) const { return mAng(mAngle + v.mAngle); }
39
41 mAng operator-(const mAng &v) const { return mAng(mAngle - v.mAngle); }
42
44 bool operator==(const mAng &v) const { return mAngle == v.mAngle; }
45
47 bool operator!=(const mAng &v) const { return mAngle != v.mAngle; }
48
50 float sin() const { return nw4r::math::SinS(mAngle); }
51
53 float cos() const { return nw4r::math::CosS(mAngle); }
54
55
56 s16 mAngle;
57};
58
61class mAng3_c {
62public:
63
66
68 mAng3_c(const s16 *p) { x = p[0]; y = p[1]; z = p[2]; }
69
71 mAng3_c(s16 fx, s16 fy, s16 fz) { x = fx; y = fy; z = fz; }
72
74 mAng3_c(const S16Vec &v) { x = v.x; y = v.y; z = v.z; }
75
77 operator s16*() { return &x; }
78
80 operator const s16*() const { return &x; }
81
83 operator S16Vec*() { return (S16Vec*)&x; }
84
86 operator const S16Vec*() const { return (const S16Vec*)&x; }
87
89 mAng3_c &operator+=(const mAng3_c &v) { x += v.x; y += v.y; z += v.z; return *this; }
90
92 mAng3_c &operator-=(const mAng3_c &v) { x -= v.x; y -= v.y; z -= v.z; return *this; }
93
95 mAng3_c operator+() const { return *this; }
96
98 mAng3_c operator-() const { return mAng3_c(-x, -y, -z); }
99
101 mAng3_c operator+(const mAng3_c &v) const { return mAng3_c(x + v.x, y + v.y, z + v.z); }
102
104 mAng3_c operator-(const mAng3_c &v) const { return mAng3_c(x - v.x, y - v.y, z - v.z); }
105
107 bool operator==(const mAng3_c &v) const { return x == v.x && y == v.y && z == v.z; }
108
110 bool operator!=(const mAng3_c &v) const { return x != v.x || y != v.y || z != v.z; }
111
112 s16 x;
113 s16 y;
114 s16 z;
115
116 static mAng3_c Zero;
117 static mAng3_c Ex;
118 static mAng3_c Ey;
119 static mAng3_c Ez;
120};
A three-dimensional short angle vector.
Definition m_angle.hpp:61
mAng3_c()
Constructs an empty vector.
Definition m_angle.hpp:65
mAng3_c operator+(const mAng3_c &v) const
Addition operator.
Definition m_angle.hpp:101
mAng3_c operator+() const
Positive operator.
Definition m_angle.hpp:95
static mAng3_c Ez
The unit rotation vector for the Z axis.
Definition m_angle.hpp:119
mAng3_c & operator-=(const mAng3_c &v)
Augmented subtraction operator.
Definition m_angle.hpp:92
static mAng3_c Ey
The unit rotation vector for the Y axis.
Definition m_angle.hpp:118
mAng3_c operator-(const mAng3_c &v) const
Subtraction operator.
Definition m_angle.hpp:104
mAng3_c & operator+=(const mAng3_c &v)
Augmented addition operator.
Definition m_angle.hpp:89
s16 y
The rotation on the Y axis.
Definition m_angle.hpp:113
s16 z
The rotation on the Z axis.
Definition m_angle.hpp:114
static mAng3_c Zero
The null rotation vector.
Definition m_angle.hpp:116
bool operator!=(const mAng3_c &v) const
Inequality operator.
Definition m_angle.hpp:110
mAng3_c(s16 fx, s16 fy, s16 fz)
Constructs a vector from three short values.
Definition m_angle.hpp:71
static mAng3_c Ex
The unit rotation vector for the X axis.
Definition m_angle.hpp:117
mAng3_c operator-() const
Negative operator.
Definition m_angle.hpp:98
bool operator==(const mAng3_c &v) const
Equality operator.
Definition m_angle.hpp:107
mAng3_c(const s16 *p)
Constructs a vector from a short array.
Definition m_angle.hpp:68
mAng3_c(const S16Vec &v)
Constructs a new vector from an existing vector from the MTX library.
Definition m_angle.hpp:74
s16 x
The rotation on the X axis.
Definition m_angle.hpp:112
float CosS(short ang)
Computes the cosine value.
float SinS(short ang)
Computes the sine value.
A three-dimensional short vector.
Definition vec.h:23
A one-dimensional short angle vector.
Definition m_angle.hpp:8
bool operator==(const mAng &v) const
Equality operator.
Definition m_angle.hpp:44
mAng & operator+=(const mAng &v)
Augmented addition operator.
Definition m_angle.hpp:26
mAng()
Constructs an empty vector.
Definition m_angle.hpp:11
mAng(const s16 *p)
Constructs a vector from a short pointer.
Definition m_angle.hpp:14
mAng operator-() const
Negative operator.
Definition m_angle.hpp:35
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
s16 mAngle
The rotation.
Definition m_angle.hpp:56
mAng & operator-=(const mAng &v)
Augmented subtraction operator.
Definition m_angle.hpp:29
mAng(s16 x)
Constructs a vector from a short value.
Definition m_angle.hpp:17
mAng operator-(const mAng &v) const
Subtraction operator.
Definition m_angle.hpp:41
mAng operator+() const
Positive operator.
Definition m_angle.hpp:32
bool operator!=(const mAng &v) const
Inequality operator.
Definition m_angle.hpp:47
mAng operator+(const mAng &v) const
Addition operator.
Definition m_angle.hpp:38