diff options
Diffstat (limited to 'xbmc/utils/Vector.cpp')
-rw-r--r-- | xbmc/utils/Vector.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/xbmc/utils/Vector.cpp b/xbmc/utils/Vector.cpp new file mode 100644 index 0000000..1f3a2fd --- /dev/null +++ b/xbmc/utils/Vector.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2012-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "Vector.h" + +#include <math.h> + +CVector& CVector::operator+=(const CVector &other) +{ + x += other.x; + y += other.y; + + return *this; +} + +CVector& CVector::operator-=(const CVector &other) +{ + x -= other.x; + y -= other.y; + + return *this; +} + +float CVector::length() const +{ + return sqrt(pow(x, 2) + pow(y, 2)); +} |