Skip to content

Commit

Permalink
vector: use c++ stdlib math functions instead of cmath
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed May 28, 2023
1 parent 078ba6d commit 438d063
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/helpers/Vector2D.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "Vector2D.hpp"
#include <algorithm>
#include <cmath>

Vector2D::Vector2D(double xx, double yy) {
x = xx;
Expand All @@ -16,7 +15,7 @@ Vector2D::~Vector2D() {}

double Vector2D::normalize() {
// get max abs
const auto max = abs(x) > abs(y) ? abs(x) : abs(y);
const auto max = std::abs(x) > std::abs(y) ? std::abs(x) : std::abs(y);

x /= max;
y /= max;
Expand All @@ -25,7 +24,7 @@ double Vector2D::normalize() {
}

Vector2D Vector2D::floor() {
return Vector2D((int)x, (int)y);
return Vector2D(std::floor(x), std::floor(y));
}

Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) {
Expand Down

0 comments on commit 438d063

Please sign in to comment.