Implement Vector-to-Vector Multiplication + division
This commit is contained in:
@@ -112,16 +112,18 @@ namespace LinearAlgebra {
|
|||||||
/// Multiplies this vector by a vector, element-wise
|
/// Multiplies this vector by a vector, element-wise
|
||||||
/// @note Mathematically, the multiplication of two vectors is not defined in linear space structures,
|
/// @note Mathematically, the multiplication of two vectors is not defined in linear space structures,
|
||||||
/// but this function is provided here for syntactical convenience.
|
/// but this function is provided here for syntactical convenience.
|
||||||
Vector2 Mul(const Vector2& v) const
|
Vector2 Mul(const Vector2& v) const;
|
||||||
{
|
|
||||||
return {this->x*v.x, this->y*v.y};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Divides this vector by a scalar.
|
/// Divides this vector by a scalar.
|
||||||
Vector2 operator /(float rhs) const;
|
Vector2 operator /(float rhs) const;
|
||||||
Vector2 Div(float scalar) const;
|
Vector2 Div(float scalar) const;
|
||||||
static Vector2 Div(const Vector2& lhs, float rhs);
|
static Vector2 Div(const Vector2& lhs, float rhs);
|
||||||
|
|
||||||
|
/// Divides this vector by a vector, element-wise
|
||||||
|
/// @note Mathematically, the multiplication of two vectors is not defined in linear space structures,
|
||||||
|
/// but this function is provided here for syntactical convenience
|
||||||
|
Vector2 Div(const Vector2& v) const;
|
||||||
|
|
||||||
/// Unary operator +
|
/// Unary operator +
|
||||||
Vector2 operator +() const; // TODO: Implement
|
Vector2 operator +() const; // TODO: Implement
|
||||||
Vector2 operator -() const;
|
Vector2 operator -() const;
|
||||||
|
@@ -243,5 +243,9 @@ namespace LinearAlgebra {
|
|||||||
return std::max(x, y);
|
return std::max(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 Vector2::Mul(const Vector2 &v) const {
|
||||||
|
return {this->x*v.x, this->y*v.y};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user