35 template<
typename T,
typename S>
49 return this->
m_data[index];
55 return this->
m_data[index];
67 if (key ==
'z' && this->
m_size >= 3)
69 if (key ==
'w' && this->
m_size >= 4)
84 if (key ==
'z' && this->
m_size >= 3)
86 if (key ==
'w' && this->
m_size >= 4)
97 for (
int i = 0; i <
size; i++)
107 for (
int i = 0; i <
size; i++)
117 for (
int i = 0; i <
size; i++)
118 this->
m_data[i] *= factor;
128 for (
int i = 0; i <
size; i++)
129 this->
m_data[i] /= factor;
139 for (
int i = 0; i <
size; i++)
140 v.data()[i] = this->
m_data[i] + other.data()[i];
149 for (
int i = 0; i <
size; i++)
150 v.data()[i] = this->
m_data[i] - other.data()[i];
160 for (
int i = 0; i <
size; i++)
161 v.data()[i] = -this->
m_data[i];
171 for (
int i = 0; i <
size; i++)
172 v += this->
m_data[i] * other.data()[i];
181 for (
int i = 0; i <
size; i++)
182 v.data()[i] = this->
m_data[i] * factor;
191 for (
int i = 0; i <
size; i++)
192 v.data()[i] = this->
m_data[i] / factor;
201 for (
int i = 0; i <
size; i++)
214 auto current = this->
length();
217 float factor = len / current;
234 template<
typename T,
typename S>
278 template<
typename T,
typename S>
300 auto b = other.data();
302 auto x = a[1] * b[2] - a[2] * b[1];
303 auto y = a[2] * b[0] - a[0] * b[2];
304 auto z = a[0] * b[1] - a[1] * b[0];
332 template<
typename T,
typename S>
342 void set(T x, T y, T z, T w)
The Tuple is a templated class inheriting from the most basic class Variant.
Definition tuple.h:27
T * data()
Gets the data array of the Tuple.
Definition tuple.h:60
int m_size
The number of elements that the data array of the Tuple holds.
Definition tuple.h:36
T * m_data
The data array of the Tuple.
Definition tuple.h:35
int size() const
Gets the number of elements of the Tuple.
Definition tuple.h:54
The class Vector2 is a templated class inheriting from the Vector class. A vector2 object holds 2 ele...
Definition vector.h:236
Vector2()
Contructs a Vector2 object with 2 elements, all initialized to 0.
Definition vector.h:240
void set(T x, T y)
Sets the values of the two elements of current Vector2 object.
Definition vector.h:246
The class Vector2f inherits from the templated class of Vector2, and the template parameters are spec...
Definition vector.h:268
Vector2f(const Vector4f &other)
Contructs a Vector2f object by copying the firt two elements of another existing vector4f object.
Vector2f(float x, float y)
Contructs a Vector2f object and sets the floats x and y to the elements.
Vector2f()
Contructs a Vector2f object, all elements initialized to 0.
Vector2f(const Vector2f &other)
Contructs a Vector2f object by copying the elements of another existing vector2f object.
Vector2f(const Vector3f &other)
Contructs a Vector2f object by copying the firt two elements of another existing vector3f object.
The class Vector2i inherits from the templated class of Vector2, and the template parameters are spec...
Definition vector.h:255
int manhattanLength() const
Vector2i(const Vector4i &other)
Contructs a Vector2i object by copying the firt two elements of another existing vector4i object.
Vector2i(const Vector3i &other)
Contructs a Vector2i object by copying the firt two elements of another existing vector3i object.
Vector2i()
Contructs a Vector2i object, all elements initialized to 0.
Vector2i(const Vector2i &other)
Contructs a Vector2i object by copying the elements of another existing vector2i object.
Vector2i(int x, int y)
Contructs a Vector2i object and sets the integers x and y to the elements.
The class Vector3 is a templated class inheriting from the Vector class. A vector3 object holds 3 ele...
Definition vector.h:280
Vector3()
Contructs a Vector3 object with 3 elements, all initialized to 0.
Definition vector.h:284
S operator^(const S &other) const
Calculates the cross product of this vector3 and another vector3, returning a new Vector3.
Definition vector.h:297
void set(T x, T y, T z)
Sets the values of the three elements of current Vector3 object.
Definition vector.h:289
The class Vector3f inherits from the templated class of Vector3, and the template parameters are spec...
Definition vector.h:322
Vector3f(const Vector4f &other)
Contructs a Vector3f object by copying the firt three elements of another existing vector4f object.
Vector3f(const Vector2f &other, float z=0)
Contructs a Vector3f object by copying the elements of another existing vector2f object,...
Vector3f(float x, float y, float z)
Contructs a Vector3f object and sets the floats x, y and z to the elements.
Vector3f()
Contructs a Vector3f object, all elements initialized to 0.
Vector3f(const Vector3f &other)
Contructs a Vector3f object by copying the elements of another existing vector3f object.
The class Vector3i inherits from the templated class of Vector3, and the template parameters are spec...
Definition vector.h:312
Vector3i(int x, int y, int z)
Contructs a Vector3i object and sets the integers x, y and z to the elements.
Vector3i(const Vector4i &other)
Contructs a Vector3i object by copying the firt three elements of another existing vector4i object.
Vector3i(const Vector3i &other)
Contructs a Vector3i object by copying the elements of another existing vector3i object.
Vector3i()
Contructs a Vector3i object, all elements initialized to 0.
Vector3i(const Vector2i &other, int z=0)
Contructs a Vector3i object by copying the elements of another existing vector2i object,...
The class Vector4 is a templated class inheriting from the Vector class. A vector4 object holds 4 ele...
Definition vector.h:334
void set(T x, T y, T z, T w)
Sets the values of the four elements of current Vector4 object.
Definition vector.h:342
Vector4()
Contructs a Vector4 object with 4 elements, all initialized to 0.
Definition vector.h:337
The class Vector4f inherits from the templated class of Vector4, and the template parameters are spec...
Definition vector.h:366
Vector4f()
Contructs a Vector4f object, all elements initialized to 0.
Vector4f(const Vector4f &other)
Contructs a Vector4f object by copying the elements of another existing vector4f object.
Vector4f(const Vector3f &other, float w=0)
Contructs a Vector4f object by copying the elements of another existing vector3f object,...
Vector4f(float x, float y, float z, float w)
Contructs a Vector4f object and sets the floats x, y, z and w to the elements.
Vector4f(const Vector2f &other, float z=0, float w=0)
Contructs a Vector4f object by copying the elements of another existing vector2f object,...
The class Vector4i inherits from the templated class of Vector4, and the template parameters are spec...
Definition vector.h:354
Vector4i()
Contructs a Vector4i object, all elements initialized to 0.
Vector4i(const Vector2i &other, int z=0, int w=0)
Contructs a Vector4i object by copying the elements of another existing vector2i object,...
Vector4i(int x, int y, int z, int w)
Contructs a Vector4i object and sets the integers x, y, z and w to the elements.
Vector4i(const Vector3i &other, int w=0)
Contructs a Vector4i object by copying the elements of another existing vector3i object,...
Vector4i(const Vector4i &other)
Contructs a Vector4i object by copying the elements of another existing vector4i object.
The Vector is a templated class inheriting from the Tuple class, and it can store a pecific number of...
Definition vector.h:37
bool normalize()
Normalize the current Vector and returns a boolean value indicating success.
Definition vector.h:227
const T & operator[](char key) const
Provides read-only access to a element within the Vector object using a character key.
Definition vector.h:61
S operator/(float factor) const
Returns a Vector object that is formed by dividing each element of the current vector by the factor.
Definition vector.h:187
const T & operator[](int index) const
Provides read-only access to the element at a specific index(position) within the Vector object.
Definition vector.h:47
S operator-(const S &other) const
Returns a Vector object that is formed by element-wise subtraction between the current Vector and ano...
Definition vector.h:145
S operator*(float factor) const
Returns a Vector object that is formed by multiplying each element of the current vector by the facto...
Definition vector.h:177
bool setLength(float len)
Changes the length of the current Vector and returns a boolean value indicating success.
Definition vector.h:212
S operator+(const S &other) const
Returns a Vector object that is formed by element-wise addition between the current Vector and anothe...
Definition vector.h:135
T squaredLength() const
Returns the squared length of the current Vector.
Definition vector.h:197
S operator-() const
Returns a Vector object that is formed by changing the sign of each element of the current vector.
Definition vector.h:156
T & operator[](char key)
Provides read-write access to a element within the Vector object using a character key.
Definition vector.h:78
Vector< T, S > & operator*=(float factor)
Performs scalar multiplication between the current Vector and a floating-point factor.
Definition vector.h:114
T operator*(const S &other) const
Returns a Vector object that is formed by element-wise multiplication between the current Vector and ...
Definition vector.h:167
Vector< T, S > & operator/=(float factor)
Performs scalar division between the current Vector and a floating-point factor.
Definition vector.h:125
float length() const
Returns the length of the current Vector.
Definition vector.h:207
Vector< T, S > & operator-=(const Vector &other)
Performs element-wise subtraction between the current Vector and another vector.
Definition vector.h:104
T & operator[](int index)
Provides read-write access to the element at a specific index(position) within the Vector object.
Definition vector.h:53
Vector(int size)
Constructs a Vector object with a specified number of elements.
Definition vector.h:41
Vector & operator+=(const Vector &other)
Performs element-wise addition between the current Vector and another vector.
Definition vector.h:94