sead
Loading...
Searching...
No Matches
seadVector.h
Go to the documentation of this file.
1#ifndef SEAD_VECTOR_H_
2#define SEAD_VECTOR_H_
3
4#include <basis/seadTypes.h>
5#include <math/seadMathPolicies.h>
6
7namespace sead {
8
9template <typename T>
10class Vector2 : public Policies<T>::Vec2Base
11{
12private:
13 typedef Vector2<T> Self;
14
15public:
16 typedef T ValueType;
17
18public:
19 constexpr Vector2()
20 {
21 }
22
23 constexpr Vector2(const Vector2& other) = default;
24
25 //Vector2(const Self& v)
26 //{
27 // operator=(v);
28 //}
29
30 constexpr Vector2(T x_, T y_);
31
32 template <typename VectorType>
33 constexpr Vector2(const VectorType& v);
34
35 Self operator*(T t) const;
36 Self operator/(T t) const;
37 Self operator+(const Self& v) const;
38 Self operator-(const Self& v) const;
39 Self operator-() const;
40
41 Self& operator*=(T t);
42 Self& operator/=(T t);
43 Self& operator+=(const Self& v);
44 Self& operator-=(const Self& v);
45 Self& operator=(const Self& v);
46
47 template <typename VectorType>
48 Self& operator=(const VectorType& v);
49
50 bool operator==(const Self& v) const;
51 bool operator!=(const Self& v) const;
52
53 T dot(const Self& t) const;
54 T squaredLength() const;
55 T length() const;
56 T squaredDistance(const Self& v) const;
57 T distance(const Self& v) const;
58
59 void add(const Self& a);
60 void div(const Self& a);
61 void multScalar(T t);
62 void divScalar(T t);
64 T setNormalize(const Self& v);
65 void set(const Self& v);
66 void set(T x_, T y_);
67 void setSub(const Self& a, const Self& b);
68 void setLerp(const Self& a, const Self& b, f32 ratio);
69
70 static const Vector2 zero;
71 static const Vector2 ex;
72 static const Vector2 ey;
73 static const Vector2 ones;
74};
75
76template <typename T>
77class Matrix33;
78
79template <typename T>
80class Matrix34;
81
82template <typename T>
83class Matrix44;
84
85template <typename T>
86class Vector3 : public Policies<T>::Vec3Base
87{
88private:
89 typedef Vector3<T> Self;
90 typedef Vector2<T> Vec2;
91 typedef Matrix33<T> Mtx33;
92 typedef Matrix34<T> Mtx34;
93 typedef Matrix44<T> Mtx44;
94
95public:
96 typedef T ValueType;
97
98public:
99 constexpr Vector3()
100 {
101 }
102
103 constexpr Vector3(const Vector3& other) = default;
104
105 //Vector3(const Self& v)
106 //{
107 // operator=(v);
108 //}
109
110 constexpr Vector3(T x_, T y_, T z_);
111 constexpr Vector3(const Vec2& vec2, T z_);
112
113 Self operator*(T t) const;
114 Self operator/(T t) const;
115 Self operator+(const Self& v) const;
116 Self operator-(const Self& v) const;
117 Self operator-() const;
118
119 Self& operator*=(T t);
120 Self& operator/=(T t);
121 Self& operator+=(const Self& v);
122 Self& operator-=(const Self& v);
123 Self& operator=(const Self& v);
124
125 bool operator==(const Self& v) const;
126 bool operator!=(const Self& v) const;
127
128 T dot(const Self& t) const;
129 T squaredLength() const;
130 T length() const;
131 T squaredDistance(const Self& v) const;
132 T distance(const Self& v) const;
133
134 void add(const Self& a);
135 void multScalar(T t);
136 void divScalar(T t);
138 T setNormalize(const Self& v);
139 void set(const Self& v);
140 void set(T x_, T y_, T z_);
141 void set(const Vec2& vec2, T z_);
142 void setAdd(const Self& a, const Self& b);
143 void setSub(const Self& a, const Self& b);
144 void setCross(const Self& a, const Self& b);
145 void setLerp(const Self& a, const Self& b, f32 ratio);
146 void setMul(const Mtx34& m, const Self& v);
147 void setRotate(const Mtx33& m, const Self& v);
148 void setRotate(const Mtx34& m, const Self& v);
149 void setMulAndDivByW(const Mtx44& m, const Self& v);
150 void setScaleAdd(T t, const Self& a, const Self& b);
151
152 static const Vector3 zero;
153 static const Vector3 ex;
154 static const Vector3 ey;
155 static const Vector3 ez;
156 static const Vector3 ones;
157};
158
159template <typename T>
160class Vector4 : public Policies<T>::Vec4Base
161{
162private:
163 typedef Vector4<T> Self;
164 typedef Vector2<T> Vec2;
165 typedef Vector3<T> Vec3;
166
167public:
168 typedef T ValueType;
169
170public:
171 constexpr Vector4()
172 {
173 }
174
175 //Vector4(const Self& v)
176 //{
177 // operator=(v);
178 //}
179
180 constexpr Vector4(T x_, T y_, T z_, T w_);
181 constexpr Vector4(const Vec2& vec2, T z_, T w_);
182 constexpr Vector4(const Vec3& vec3, T w_);
183
184 constexpr Vector4(const Vector4& other) = default;
185
186 Self operator*(T t) const;
187 Self operator/(T t) const;
188 Self operator+(const Self& v) const;
189 Self operator-(const Self& v) const;
190 Self operator-() const;
191
192 Self& operator*=(T t);
193 Self& operator/=(T t);
194 Self& operator+=(const Self& v);
195 Self& operator-=(const Self& v);
196 Self& operator=(const Self& v);
197
198 bool operator==(const Self& v) const;
199 bool operator!=(const Self& v) const;
200
201 T dot(const Self& t) const;
202 T squaredLength() const;
203 T length() const;
204 T squaredDistance(const Self& v) const;
205 T distance(const Self& v) const;
206
207 void multScalar(T t);
208 void divScalar(T t);
210 T setNormalize(const Self& v);
211 void set(const Self& v);
212 void set(T x_, T y_, T z_, T w_);
213 void set(const Vec2& vec2, T z_, T w_);
214 void set(const Vec3& vec3, T w_);
215 void setLerp(const Self& a, const Self& b, f32 ratio);
216
217 static const Vector4 zero;
218 static const Vector4 ex;
219 static const Vector4 ey;
220 static const Vector4 ez;
221 static const Vector4 ew;
222 static const Vector4 ones;
223};
224
225template <typename T>
226Vector2<T> operator*(T t, const Vector2<T>& v);
227
228template <typename T>
229Vector3<T> operator*(T t, const Vector3<T>& v);
230
231template <typename T>
232Vector4<T> operator*(T t, const Vector4<T>& v);
233
237
241
245
246#ifdef cafe
247static_assert(sizeof(Vector2f) == 8, "sead::Vector2<T> size mismatch");
248static_assert(sizeof(Vector3f) == 0xC, "sead::Vector3<T> size mismatch");
249static_assert(sizeof(Vector4f) == 0x10, "sead::Vector4<T> size mismatch");
250#endif // cafe
251
252template <>
254
255template <>
257
258template <>
260
261template <>
263
264template <>
266
267template <>
269
270template <>
272
273template <>
275
276template <>
278
279template <>
281
282template <>
284
285template <>
287
288template <>
290
291template <>
293
294template <>
296
297} // namespace sead
298
299#ifdef __cplusplus
300
301#include <math/seadVector.hpp>
302
303#endif // __cplusplus
304
305#endif // #define SEAD_VECTOR_H_
Definition seadMatrix.h:63
Definition seadMatrix.h:121
Definition seadMatrix.h:226
Definition seadMathPolicies.h:8
Definition seadVector.h:11
static const Vector2 ey
Definition seadVector.h:72
Self operator*(T t) const
Definition seadVector.hpp:24
Self & operator=(const Self &v)
Definition seadVector.hpp:112
Self & operator*=(T t)
Definition seadVector.hpp:80
Self & operator+=(const Self &v)
Definition seadVector.hpp:96
T squaredDistance(const Self &v) const
Definition seadVector.hpp:166
T dot(const Self &t) const
Definition seadVector.hpp:145
constexpr Vector2(const VectorType &v)
Definition seadVector.hpp:17
void multScalar(T t)
Definition seadVector.hpp:194
T distance(const Self &v) const
Definition seadVector.hpp:173
T length() const
Definition seadVector.hpp:159
Self operator+(const Self &v) const
Definition seadVector.hpp:51
Self operator-() const
Definition seadVector.hpp:71
static const Vector2 ones
Definition seadVector.h:73
T ValueType
Definition seadVector.h:16
T normalize()
Definition seadVector.hpp:201
void add(const Self &a)
Definition seadVector.hpp:180
Self & operator-=(const Self &v)
Definition seadVector.hpp:104
Self operator-(const Self &v) const
Definition seadVector.hpp:61
constexpr Vector2(const Vector2 &other)=default
Self & operator=(const VectorType &v)
Self operator/(T t) const
Definition seadVector.hpp:42
static const Vector2 zero
Definition seadVector.h:70
T setNormalize(const Self &v)
Definition seadVector.hpp:208
void set(T x_, T y_)
Definition seadVector.hpp:222
static const Vector2 ex
Definition seadVector.h:71
void setSub(const Self &a, const Self &b)
Definition seadVector.hpp:229
Vector2< T > Self
Definition seadVector.h:13
void div(const Self &a)
Definition seadVector.hpp:187
void set(const Self &v)
Definition seadVector.hpp:215
Self & operator/=(T t)
Definition seadVector.hpp:88
void divScalar(T t)
T squaredLength() const
Definition seadVector.hpp:152
bool operator!=(const Self &v) const
Definition seadVector.hpp:138
void setLerp(const Self &a, const Self &b, f32 ratio)
Definition seadVector.hpp:236
constexpr Vector2(T x_, T y_)
Definition seadVector.hpp:9
bool operator==(const Self &v) const
Definition seadVector.hpp:131
constexpr Vector2()
Definition seadVector.h:19
Definition seadVector.h:87
Self operator-(const Self &v) const
Definition seadVector.hpp:294
static const Vector3 ez
Definition seadVector.h:155
constexpr Vector3(const Vec2 &vec2, T z_)
Definition seadVector.hpp:250
constexpr Vector3(T x_, T y_, T z_)
Definition seadVector.hpp:243
void setSub(const Self &a, const Self &b)
Definition seadVector.hpp:460
T length() const
Definition seadVector.hpp:383
Self & operator/=(T t)
Definition seadVector.hpp:321
Matrix33< T > Mtx33
Definition seadVector.h:91
T dot(const Self &t) const
Definition seadVector.hpp:369
Self operator/(T t) const
Definition seadVector.hpp:275
void set(T x_, T y_, T z_)
Definition seadVector.hpp:439
void setMulAndDivByW(const Mtx44 &m, const Self &v)
constexpr Vector3(const Vector3 &other)=default
T normalize()
Definition seadVector.hpp:418
void setScaleAdd(T t, const Self &a, const Self &b)
Definition seadVector.hpp:502
void divScalar(T t)
void setMul(const Mtx34 &m, const Self &v)
Definition seadVector.hpp:481
T setNormalize(const Self &v)
Definition seadVector.hpp:425
static const Vector3 zero
Definition seadVector.h:152
T squaredLength() const
Definition seadVector.hpp:376
Matrix44< T > Mtx44
Definition seadVector.h:93
Self & operator=(const Self &v)
Definition seadVector.hpp:345
static const Vector3 ey
Definition seadVector.h:154
Self & operator+=(const Self &v)
Definition seadVector.hpp:329
void set(const Self &v)
Definition seadVector.hpp:432
Self operator+(const Self &v) const
Definition seadVector.hpp:284
Self operator*(T t) const
Definition seadVector.hpp:257
T squaredDistance(const Self &v) const
Definition seadVector.hpp:390
static const Vector3 ex
Definition seadVector.h:153
void setAdd(const Self &a, const Self &b)
Definition seadVector.hpp:453
bool operator!=(const Self &v) const
Definition seadVector.hpp:362
Matrix34< T > Mtx34
Definition seadVector.h:92
bool operator==(const Self &v) const
Definition seadVector.hpp:355
T distance(const Self &v) const
Definition seadVector.hpp:397
constexpr Vector3()
Definition seadVector.h:99
void setLerp(const Self &a, const Self &b, f32 ratio)
Definition seadVector.hpp:474
void setRotate(const Mtx33 &m, const Self &v)
Definition seadVector.hpp:488
Self operator-() const
Definition seadVector.hpp:304
Vector3< T > Self
Definition seadVector.h:89
void multScalar(T t)
Definition seadVector.hpp:411
void set(const Vec2 &vec2, T z_)
Definition seadVector.hpp:446
void setRotate(const Mtx34 &m, const Self &v)
Definition seadVector.hpp:495
static const Vector3 ones
Definition seadVector.h:156
void add(const Self &a)
Definition seadVector.hpp:404
Vector2< T > Vec2
Definition seadVector.h:90
Self & operator-=(const Self &v)
Definition seadVector.hpp:337
Self & operator*=(T t)
Definition seadVector.hpp:313
void setCross(const Self &a, const Self &b)
Definition seadVector.hpp:467
T ValueType
Definition seadVector.h:96
Definition seadVector.h:161
Self operator-(const Self &v) const
Definition seadVector.hpp:567
static const Vector4 ones
Definition seadVector.h:222
Self operator+(const Self &v) const
Definition seadVector.hpp:557
void divScalar(T t)
Self operator/(T t) const
Definition seadVector.hpp:548
T squaredDistance(const Self &v) const
Definition seadVector.hpp:664
constexpr Vector4()
Definition seadVector.h:171
void multScalar(T t)
Definition seadVector.hpp:678
Self & operator+=(const Self &v)
Definition seadVector.hpp:602
static const Vector4 ez
Definition seadVector.h:220
constexpr Vector4(T x_, T y_, T z_, T w_)
Definition seadVector.hpp:509
Self & operator*=(T t)
Definition seadVector.hpp:586
T normalize()
Definition seadVector.hpp:685
Self & operator/=(T t)
Definition seadVector.hpp:594
static const Vector4 ex
Definition seadVector.h:218
constexpr Vector4(const Vector4 &other)=default
Vector4< T > Self
Definition seadVector.h:163
void set(const Vec3 &vec3, T w_)
Definition seadVector.hpp:720
Self operator*(T t) const
Definition seadVector.hpp:530
Self & operator-=(const Self &v)
Definition seadVector.hpp:610
Vector2< T > Vec2
Definition seadVector.h:164
T distance(const Self &v) const
Definition seadVector.hpp:671
T length() const
Definition seadVector.hpp:657
Self & operator=(const Self &v)
Definition seadVector.hpp:618
T dot(const Self &t) const
Definition seadVector.hpp:643
Vector3< T > Vec3
Definition seadVector.h:165
void set(const Vec2 &vec2, T z_, T w_)
Definition seadVector.hpp:713
T setNormalize(const Self &v)
Definition seadVector.hpp:692
Self operator-() const
Definition seadVector.hpp:577
void set(T x_, T y_, T z_, T w_)
Definition seadVector.hpp:706
bool operator!=(const Self &v) const
Definition seadVector.hpp:636
constexpr Vector4(const Vec2 &vec2, T z_, T w_)
Definition seadVector.hpp:516
void set(const Self &v)
Definition seadVector.hpp:699
static const Vector4 ey
Definition seadVector.h:219
constexpr Vector4(const Vec3 &vec3, T w_)
Definition seadVector.hpp:523
bool operator==(const Self &v) const
Definition seadVector.hpp:629
void setLerp(const Self &a, const Self &b, f32 ratio)
Definition seadVector.hpp:727
static const Vector4 zero
Definition seadVector.h:217
T squaredLength() const
Definition seadVector.hpp:650
static const Vector4 ew
Definition seadVector.h:221
T ValueType
Definition seadVector.h:168
Definition seadAssert.h:44
Vector2< f32 > Vector2f
Definition seadVector.h:238
Vector2< u32 > Vector2u
Definition seadVector.h:242
Vector3< T > operator*(T t, const Vector3< T > &v)
Definition seadVector.hpp:266
Vector4< T > operator*(T t, const Vector4< T > &v)
Definition seadVector.hpp:539
Vector3< s32 > Vector3i
Definition seadVector.h:235
Vector2< s32 > Vector2i
Definition seadVector.h:234
Vector4< u32 > Vector4u
Definition seadVector.h:244
Vector3< u32 > Vector3u
Definition seadVector.h:243
Vector2< T > operator*(T t, const Vector2< T > &v)
Definition seadVector.hpp:33
Vector3< f32 > Vector3f
Definition seadVector.h:239
Vector4< f32 > Vector4f
Definition seadVector.h:240
Vector4< s32 > Vector4i
Definition seadVector.h:236