summaryrefslogtreecommitdiffstats
path: root/PositionI.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--PositionI.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/PositionI.cpp b/PositionI.cpp
index 7180527..b9257a1 100644
--- a/PositionI.cpp
+++ b/PositionI.cpp
@@ -1,3 +1,4 @@
+#include <cmath>
#include "PositionI.hpp"
PositionI::PositionI(int x, int z, int y) : m_x(x), m_y(y), m_z(z) {
@@ -76,3 +77,15 @@ bool PositionI::operator<=(const PositionI &rhs) const {
bool PositionI::operator>=(const PositionI &rhs) const {
return !(*this < rhs);
}
+
+PositionI PositionI::operator-(const PositionI &other) const {
+ return PositionI(
+ m_x - other.m_x,
+ m_z - other.m_z,
+ m_y - other.m_y
+ );
+}
+
+double PositionI::GetDistance() {
+ return (std::sqrt(std::pow(m_x, 2) + std::pow(m_y, 2) + std::pow(m_z, 2)));
+}