summaryrefslogtreecommitdiff
path: root/src/helpers/Vector2D.cpp
diff options
context:
space:
mode:
authorChing Pei Yang <59727193+horriblename@users.noreply.github.com>2023-02-18 23:35:31 +0100
committerGitHub <noreply@github.com>2023-02-18 22:35:31 +0000
commitc92e0c05e466f8cbf9c99ddcff969a1b36277248 (patch)
treed461585fc9df2880848378128942403f7990f08e /src/helpers/Vector2D.cpp
parentb944386ca54cf650d660caac31f065c0211168b1 (diff)
Resize on border (#1347)
Diffstat (limited to 'src/helpers/Vector2D.cpp')
-rw-r--r--src/helpers/Vector2D.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/helpers/Vector2D.cpp b/src/helpers/Vector2D.cpp
index 97a9685c..3ab3ce43 100644
--- a/src/helpers/Vector2D.cpp
+++ b/src/helpers/Vector2D.cpp
@@ -29,4 +29,10 @@ Vector2D Vector2D::floor() {
Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) {
return Vector2D(std::clamp(this->x, min.x, max.x == 0 ? INFINITY : max.x), std::clamp(this->y, min.y, max.y == 0 ? INFINITY : max.y));
-} \ No newline at end of file
+}
+
+double Vector2D::distance(const Vector2D& other) {
+ double dx = x - other.x;
+ double dy = y - other.y;
+ return std::sqrt(dx * dx + dy * dy);
+}