26 array<float, 4>
data { 0.0f, 0.0f, 0.0f, 0.0f };
42 inline Vector4(
float x,
float y,
float z,
float w) {
53 inline Vector4(
const array<float, 4>& vector4) {
82 inline Vector4(
const array<float, 3>& vector3,
float w) {
97 inline Vector4&
set(
float x,
float y,
float z,
float w) {
292 return (
this == &vector4) ||
347 (b.
data[0] * t) + ((1.0f - t) * a.
data[0]),
348 (b.
data[1] * t) + ((1.0f - t) * a.
data[1]),
349 (b.
data[2] * t) + ((1.0f - t) * a.
data[2]),
350 (b.
data[3] * t) + ((1.0f - t) * a.
data[3])
403 auto r = this->
clone().
add(vector4);
423 auto r = this->
clone().
sub(vector4);
453 auto vInverted =
Vector4(1.0f / scalar, 1.0f / scalar, 1.0f / scalar, 1.0f / scalar);
464 auto vInverted =
Vector4(1.0f / vector4[0], 1.0f / vector4[1], 1.0f / vector4[2], 1.0f / vector4[3]);
475 return this->
add(scalar);
484 return this->
add(vector4);
493 return this->
sub(scalar);
502 return this->
sub(vector4);
511 return this->
scale(scalar);
520 return this->
scale(vector4);
529 auto vInverted =
Vector4(1.0f / scalar, 1.0f / scalar, 1.0f / scalar, 1.0f / scalar);
530 return this->
scale(vInverted);
539 auto vInverted =
Vector4(1.0f / vector4[0], 1.0f / vector4[1], 1.0f / vector4[2], 1.0f / vector4[3]);
540 return this->
scale(vInverted);
549 return this->
equals(vector4);
558 return this->
equals(vector4) ==
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.
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Vector4 class representing vector4 mathematical structure and operations with x, y,...
static float computeDotProduct(const Vector4 &a, const Vector4 &b)
Compute the dot product of a and b.
const float & operator[](int i) const
Const array access operator.
Vector4 & set(float x, float y, float z, float w)
Sets this vector4 by its components.
float & operator[](int i)
Array access operator.
Vector4 clone() const
Clones this vector4.
float computeLength() const
Vector4 & setY(float y)
Sets y component.
Vector4 & operator/=(const float scalar)
Operator /= scalar.
Vector4 & set(const Vector4 &vector4)
Sets this vector4 by given vector4.
Vector4 & set(const array< float, 4 > &vector4)
Sets this vector4 by array.
bool equals(const Vector4 &vector4, float tolerance=Math::EPSILON) const
Compares this vector4 with given vector4.
Vector4 & normalize()
Normalizes this vector4.
Vector4()
Public constructor.
Vector4 & sub(const Vector4 &vector4)
Subtracts a vector4.
Vector4(float x, float y, float z, float w)
Public constructor.
Vector4(const array< float, 4 > &vector4)
Public constructor.
Vector4(const Vector3 &vector3, float w)
Public constructor.
Vector4 & scale(const Vector4 &vector4)
Scales this vector4.
Vector4 operator+(const float scalar) const
Operator + scalar.
Vector4 & setW(float w)
Sets w component.
Vector4 & sub(float scalar)
Subtracts a scalar.
Vector4 operator*(const float scalar) const
Operator * scalar.
Vector4 & set(const Vector3 &vector3, float w)
Sets this vector4 by given vector3 and w.
float computeLengthSquared() const
Vector4 & setZ(float z)
Sets z component.
Vector4 & scale(float scalar)
Scales this vector4.
Vector4(const Vector4 &vector4)
Public constructor.
Vector4 & add(const Vector4 &vector4)
Adds a vector4.
Vector4 & add(float scalar)
Adds a scalar.
Vector4(const array< float, 3 > &vector3, float w)
Public constructor.
const array< float, 4 > & getArray() const
Vector4 operator/(const float scalar) const
Operator / scalar.
Vector4 & setX(float x)
Sets x component.
static Vector4 interpolateLinear(const Vector4 &a, const Vector4 &b, float t)
Interpolates between a and b by 0f<=t<=1f linearly.
bool operator!=(const Vector4 &vector4) const
Non equality comparison operator.
Vector4 & operator+=(const float scalar)
Operator += scalar.
Vector4 operator-(const float scalar) const
Operator - scalar.
Vector4 & operator*=(const float scalar)
Operator *= scalar.
bool operator==(const Vector4 &vector4) const
Equality comparison operator.
Vector4 & operator-=(const float scalar)
Operator -= scalar.