Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/vector2f.cc')
-rw-r--r--src/math/vector2f.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/math/vector2f.cc b/src/math/vector2f.cc
index 878304f..bff60c9 100644
--- a/src/math/vector2f.cc
+++ b/src/math/vector2f.cc
@@ -63,6 +63,25 @@ Vector2f &Vector2f::operator-=(const Vector2f &other)
return (*this);
}
+Vector2f & Vector2f::operator*=(const float scalar)
+{
+ coord[0] *= scalar;
+ coord[1] *= scalar;
+ return (*this);
+}
+
+Vector2f & Vector2f::operator/=(const float scalar)
+{
+ coord[0] /= scalar;
+ coord[1] /= scalar;
+ return (*this);
+}
+
+float Vector2f::length() const
+{
+ return (sqrtf((coord[0] * coord[0]) + (coord[1] * coord[1])));
+}
+
float distance(const Vector2f& first, const Vector2f& second)
{
float r = 0;
@@ -80,4 +99,9 @@ float distancesquared(const Vector2f& first, const Vector2f& second)
return (r);
}
+Vector2f operator*(float scalar, const Vector2f &vector)
+{
+ return vector * scalar;
+}
+
}