8#define TP_VEC_ALIAS(name, index) \
9T& name() { return _values[index]; static_assert(index <= i, "Attempt to use an alias that doesn't exist for this TeaPacket Vector type! Alias index: " #index "." ); }; \
10const T& name() const { return _values[index]; static_assert(index <= i, "Attempt to use an alias that doesn't exist for this TeaPacket Vector type! Alias index: " #index "."); }; \
12#define TP_VEC_MATH_OPERATOR(OP) \
13template<unsigned char s> \
14Vector<T,i>& operator OP##= (const Vector<T,s>& other) \
16 static_assert(i >= s, "Left side Vector must have a larger or equal size to the Right side Vector when performing math operations."); \
17 for(unsigned char j = 0; j < s; j++) \
19 this[j] OP##= other[j]; \
23template<unsigned char s> \
24Vector<T,i> operator OP (const Vector<T,s>& other) const \
26 static_assert(i >= s, "Left side Vector must have a larger or equal size to the Right side Vector when performing math operations."); \
27 Vector<T,i> vec = this; \
28 return vec OP##= other; \
35 template<
typename T,
unsigned char i>
39 static_assert(std::is_arithmetic_v<T>,
"Provided Vector type is not an arithmetic type.");
71 bool operator==(
Vector<T,i> const& other)
const
73 for (
unsigned char j = 0; j < i; j++)
75 if (other[j] !=
this[j])
88 return !(
this==other);
92 template<
typename O,
unsigned char s>
96 constexpr unsigned char minsize = (std::min)(s,i);
97 for (
unsigned char j = 0; j < minsize; j++)
106 return std::array<T,i>(_values);
110 operator std::string()
const
112 std::string str =
"{";
113 for (
unsigned char j = 0; j < i; j++)
115 str += std::to_string(_values[j]) +
",";
130 std::copy(il.begin(), il.end(), _values);
140#define TP_VECTOR_TYPE_GEN_SOLO(size, type, typeInitial) \
141typedef TeaPacket::Math::Vector<type, size> Vector##size##typeInitial;
143#define TP_VECTOR_TYPE_GEN(vecsize) \
144TP_VECTOR_TYPE_GEN_SOLO(vecsize, float, ) \
145TP_VECTOR_TYPE_GEN_SOLO(vecsize, float, f) \
146TP_VECTOR_TYPE_GEN_SOLO(vecsize, double, d) \
148TP_VECTOR_TYPE_GEN_SOLO(vecsize, signed char, sb) \
149TP_VECTOR_TYPE_GEN_SOLO(vecsize, char, b) \
150TP_VECTOR_TYPE_GEN_SOLO(vecsize, unsigned char, ub) \
151TP_VECTOR_TYPE_GEN_SOLO(vecsize, short, s) \
152TP_VECTOR_TYPE_GEN_SOLO(vecsize, signed short, ss) \
153TP_VECTOR_TYPE_GEN_SOLO(vecsize, unsigned short, us) \
154TP_VECTOR_TYPE_GEN_SOLO(vecsize, int, i) \
155TP_VECTOR_TYPE_GEN_SOLO(vecsize, signed int, si) \
156TP_VECTOR_TYPE_GEN_SOLO(vecsize, unsigned int, ui) \
157TP_VECTOR_TYPE_GEN_SOLO(vecsize, long, l) \
158TP_VECTOR_TYPE_GEN_SOLO(vecsize, signed long, sl) \
159TP_VECTOR_TYPE_GEN_SOLO(vecsize, unsigned long, ul) \
160TP_VECTOR_TYPE_GEN_SOLO(vecsize, long long, ll) \
161TP_VECTOR_TYPE_GEN_SOLO(vecsize, signed long long, sll) \
162TP_VECTOR_TYPE_GEN_SOLO(vecsize, unsigned long long, ull)
#define TP_VEC_MATH_OPERATOR(OP)
Definition Vector.hpp:12
#define TP_VEC_ALIAS(name, index)
Definition Vector.hpp:8
T & v()
Definition Vector.hpp:52
Vector()
Default initializer, setting all values to garbage data.
Definition Vector.hpp:122
T & y()
Definition Vector.hpp:42
T & g()
Definition Vector.hpp:47
T & a()
Definition Vector.hpp:49
T & r()
Definition Vector.hpp:46
bool operator!=(Vector< T, i > const &other) const
Definition Vector.hpp:86
T & b()
Definition Vector.hpp:48
std::array< T, i > GetAsArray() const
Get a copy of the Vector as a plain std::array.
Definition Vector.hpp:104
T & w()
Definition Vector.hpp:44
T & u()
Definition Vector.hpp:51
Vector(std::initializer_list< T > il)
Initializer list, sets all values to the given values in the list.
Definition Vector.hpp:128
T & z()
Definition Vector.hpp:43
T & x()
Definition Vector.hpp:41
Math related functions and classes for TeaPacket.
Definition Vector.hpp:33