diff --git a/include/J3ML/LinearAlgebra/Vector2.h b/include/J3ML/LinearAlgebra/Vector2.h index d007503..286e80b 100644 --- a/include/J3ML/LinearAlgebra/Vector2.h +++ b/include/J3ML/LinearAlgebra/Vector2.h @@ -31,6 +31,8 @@ namespace J3ML::LinearAlgebra { void SetX(float newX); void SetY(float newY); + Vector2 Abs() const; + bool IsWithinMarginOfError(const Vector2& rhs, float margin=0.001f) const; bool IsNormalized(float epsilonSq = 1e-5f) const; diff --git a/src/J3ML/LinearAlgebra/Vector2.cpp b/src/J3ML/LinearAlgebra/Vector2.cpp index 388d578..5e15bbc 100644 --- a/src/J3ML/LinearAlgebra/Vector2.cpp +++ b/src/J3ML/LinearAlgebra/Vector2.cpp @@ -253,4 +253,6 @@ namespace J3ML::LinearAlgebra { Vector2 Vector2::Div(const Vector2 &v) const { return {this->x/v.x, this->y/v.y}; } + + Vector2 Vector2::Abs() const { return {std::abs(x), std::abs(y)};} } \ No newline at end of file