24 array<float, 2>
data { 0.0f, 0.0f };
47 inline Vector2(
const array<float, 2>& vector2) {
94 inline float getX()
const {
198 return (
this == &vector2) ||
249 (b.
data[0] * t) + ((1.0f - t) * a.
data[0]),
250 (b.
data[1] * t) + ((1.0f - t) * a.
data[1])
303 auto r = this->
clone().
add(vector2);
323 auto r = this->
clone().
sub(vector2);
363 auto vInverted =
Vector2(1.0f / vector2[0], 1.0f / vector2[1]);
374 return this->
add(scalar);
383 return this->
add(vector2);
392 return this->
sub(scalar);
401 return this->
sub(vector2);
410 return this->
scale(scalar);
419 return this->
scale(vector2);
428 auto vInverted =
Vector2(1.0f / scalar, 1.0f / scalar);
429 return this->
scale(vInverted);
438 auto vInverted =
Vector2(1.0f / vector2[0], 1.0f / vector2[1]);
439 return this->
scale(vInverted);
448 return this->
equals(vector2);
457 return this->
equals(vector2) ==
false;
static float sqrt(float value)
Returns the square root of given value.
static constexpr float EPSILON
static auto abs(auto value)
Returns absolute value.
Matrix3x3 class representing matrix3x3 mathematical structure and operations for 2d space.
Vector2 class representing vector2 mathematical structure and operations with x, y components.
Vector2 & operator+=(const float scalar)
Operator += scalar.
Vector2(const array< float, 2 > &vector2)
Public constructor.
const float & operator[](int i) const
Const array access operator.
Vector2(const Vector2 &vector2)
Public constructor.
Vector2 & sub(float scalar)
Subtracts a scalar.
float & operator[](int i)
Array access operator.
float computeLength() const
Vector2 & scale(const float scalar)
Scales by scalar.
Vector2 clone() const
Clones this vector2.
Vector2 & operator*=(const float scalar)
Operator *= scalar.
Vector2 operator-(const float scalar) const
Operator - scalar.
Vector2 & operator-=(const float scalar)
Operator -= scalar.
static Vector2 interpolateLinear(const Vector2 &a, const Vector2 &b, float t)
Interpolates between a and b by 0f<=t<=1f linearly.
Vector2()
Public constructor.
Vector2 & normalize()
Normalizes this vector2.
Vector2 operator+(const float scalar) const
Operator + scalar.
Vector2 operator*(const float scalar) const
Operator * scalar.
Vector2 & setX(float x)
Sets x component.
Vector2 & set(const Vector2 &vector2)
Sets this vector2 by given vector2.
Vector2 & add(float scalar)
Adds a scalar.
const array< float, 2 > & getArray() const
Vector2 & set(const array< float, 2 > &vector2)
Sets this vector2 by array.
bool equals(const Vector2 &vector2, float tolerance=Math::EPSILON) const
Compares this vector2 with given vector2.
float computeLengthSquared() const
Vector2 & scale(const Vector2 &scale)
Scales by vector2.
Vector2 operator/(const float scalar) const
Operator / scalar.
static float computeDotProduct(const Vector2 &a, const Vector2 &b)
Computes the dot product of a and b.
Vector2 & setY(float y)
Sets y component.
Vector2 & sub(const Vector2 &vector2)
Subtracts a vector2.
bool operator!=(const Vector2 &vector2) const
Non equality comparison operator.
bool operator==(const Vector2 &vector2) const
Equality comparison operator.
Vector2 & operator/=(const float scalar)
Operator /= scalar.
Vector2 & add(const Vector2 &vector2)
Adds a vector2.
Vector2(float x, float y)
Public constructor.
Vector2 & set(float x, float y)
Sets this vector2 by its components.