summaryrefslogtreecommitdiffstats
path: root/PositionI.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-12 15:49:50 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-12 15:49:50 +0200
commite62817b8252974b8a98393275874ee303840bf13 (patch)
tree4565935f06e369f4a84410b0c098958e07a750c7 /PositionI.cpp
parent2017-05-10 (diff)
downloadAltCraft-e62817b8252974b8a98393275874ee303840bf13.tar
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.gz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.bz2
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.lz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.xz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.zst
AltCraft-e62817b8252974b8a98393275874ee303840bf13.zip
Diffstat (limited to 'PositionI.cpp')
-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)));
+}