diff --git a/src/core/model/vector.cc b/src/core/model/vector.cc index 42aceb79f..4d6bb2106 100644 --- a/src/core/model/vector.cc +++ b/src/core/model/vector.cc @@ -75,6 +75,19 @@ Vector2D::Vector2D () NS_LOG_FUNCTION (this); } +double +Vector3D::GetLength () const +{ + NS_LOG_FUNCTION (this); + return std::sqrt (x * x + y * y + z * z); +} +double +Vector2D::GetLength () const +{ + NS_LOG_FUNCTION (this); + return std::sqrt (x * x + y * y); +} + double CalculateDistance (const Vector3D &a, const Vector3D &b) { diff --git a/src/core/model/vector.h b/src/core/model/vector.h index 6fe2bae1c..4ff8007d5 100644 --- a/src/core/model/vector.h +++ b/src/core/model/vector.h @@ -63,6 +63,7 @@ public: */ double z; + double GetLength () const; friend double CalculateDistance (const Vector3D &a, const Vector3D &b); friend std::ostream &operator << (std::ostream &os, const Vector3D &vector); friend std::istream &operator >> (std::istream &is, Vector3D &vector); @@ -96,6 +97,7 @@ public: */ double y; + double GetLength () const; friend double CalculateDistance (const Vector2D &a, const Vector2D &b); friend std::ostream &operator << (std::ostream &os, const Vector2D &vector); friend std::istream &operator >> (std::istream &is, Vector2D &vector);