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 s16 mAngle;
56};
57
60class mAng3_c {
61public:
62
65
67 mAng3_c(const s16 *p) { x = p[0]; y = p[1]; z = p[2]; }
68
70 mAng3_c(s16 fx, s16 fy, s16 fz) { x = fx; y = fy; z = fz; }
71
73 mAng3_c(const S16Vec &v) { x = v.x; y = v.y; z = v.z; }
74
76 operator s16*() { return &x; }
77
79 operator const s16*() const { return &x; }
80
82 operator S16Vec*() { return (S16Vec*)&x; }
83
85 operator const S16Vec*() const { return (const S16Vec*)&x; }
86
88 mAng3_c &operator+=(const mAng3_c &v) { x += v.x; y += v.y; z += v.z; return *this; }
89
91 mAng3_c &operator-=(const mAng3_c &v) { x -= v.x; y -= v.y; z -= v.z; return *this; }
92
94 mAng3_c operator+() const { return *this; }
95
97 mAng3_c operator-() const { return mAng3_c(-x, -y, -z); }
98
100 mAng3_c operator+(const mAng3_c &v) const { return mAng3_c(x + v.x, y + v.y, z + v.z); }
101
103 mAng3_c operator-(const mAng3_c &v) const { return mAng3_c(x - v.x, y - v.y, z - v.z); }
104
106 bool operator==(const mAng3_c &v) const { return x == v.x && y == v.y && z == v.z; }
107
109 bool operator!=(const mAng3_c &v) const { return x != v.x || y != v.y || z != v.z; }
110
111 s16 x;
112 s16 y;
113 s16 z;
114
115 static mAng3_c Zero;
116 static mAng3_c Ex;
117 static mAng3_c Ey;
118 static mAng3_c Ez;
119};
A three-dimensional short angle vector.
Definition m_angle.hpp:60
mAng3_c()
Constructs an empty vector.
Definition m_angle.hpp:64
mAng3_c operator+(const mAng3_c &v) const
Addition operator.
Definition m_angle.hpp:100
mAng3_c operator+() const
Positive operator.
Definition m_angle.hpp:94
static mAng3_c Ez
The unit rotation vector for the Z axis.
Definition m_angle.hpp:118
mAng3_c & operator-=(const mAng3_c &v)
Augmented subtraction operator.
Definition m_angle.hpp:91
static mAng3_c Ey
The unit rotation vector for the Y axis.
Definition m_angle.hpp:117
mAng3_c operator-(const mAng3_c &v) const
Subtraction operator.
Definition m_angle.hpp:103
mAng3_c & operator+=(const mAng3_c &v)
Augmented addition operator.
Definition m_angle.hpp:88
s16 y
The rotation on the Y axis.
Definition m_angle.hpp:112
s16 z
The rotation on the Z axis.
Definition m_angle.hpp:113
static mAng3_c Zero
The null rotation vector.
Definition m_angle.hpp:115
bool operator!=(const mAng3_c &v) const
Inequality operator.
Definition m_angle.hpp:109
mAng3_c(s16 fx, s16 fy, s16 fz)
Constructs a vector from three short values.
Definition m_angle.hpp:70
static mAng3_c Ex
The unit rotation vector for the X axis.
Definition m_angle.hpp:116
mAng3_c operator-() const
Negative operator.
Definition m_angle.hpp:97
bool operator==(const mAng3_c &v) const
Equality operator.
Definition m_angle.hpp:106
mAng3_c(const s16 *p)
Constructs a vector from a short array.
Definition m_angle.hpp:67
mAng3_c(const S16Vec &v)
Constructs a new vector from an existing vector from the MTX library.
Definition m_angle.hpp:73
s16 x
The rotation on the X axis.
Definition m_angle.hpp:111
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:55
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