core: Implement Vector{2,3}D::GetLength ()

This commit is contained in:
Alexander Krotov
2017-04-04 19:31:26 +03:00
parent ddf07b01ca
commit 2d447bfeba
2 changed files with 15 additions and 0 deletions

View File

@@ -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)
{

View File

@@ -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);