aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Vector2.hpp
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-21 17:32:04 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-21 17:32:04 +0100
commitc3b558b6b622c16badf2f325b5422f3b042009b4 (patch)
treee03b2a3d049bfef5d710bb06603aab41f9599823 /src/crepe/api/Vector2.hpp
parentea95685b4dd2adf09a9be4e2dd9233d0cf98b1ef (diff)
Extended Vector2
Diffstat (limited to 'src/crepe/api/Vector2.hpp')
-rw-r--r--src/crepe/api/Vector2.hpp94
1 files changed, 83 insertions, 11 deletions
diff --git a/src/crepe/api/Vector2.hpp b/src/crepe/api/Vector2.hpp
index e0ac3d4..46553f9 100644
--- a/src/crepe/api/Vector2.hpp
+++ b/src/crepe/api/Vector2.hpp
@@ -3,19 +3,43 @@
namespace crepe {
template <class T>
-Vector2<T> Vector2<T>::operator-(const Vector2<T> & other) const { return {x - other.x, y - other.y}; }
+Vector2<T> Vector2<T>::operator-(const Vector2<T> & other) const {
+ return {x - other.x, y - other.y};
+}
template <class T>
-Vector2<T> Vector2<T>::operator+(const Vector2<T> & other) const { return {x + other.x, y + other.y}; }
+Vector2<T> Vector2<T>::operator-(T scalar) const {
+ return {x - scalar, y - scalar};
+}
template <class T>
-Vector2<T> Vector2<T>::operator*(double scalar) const { return {x * scalar, y * scalar}; }
+Vector2<T> Vector2<T>::operator+(const Vector2<T> & other) const {
+ return {x + other.x, y + other.y};
+}
template <class T>
-Vector2<T> & Vector2<T>::operator*=(const Vector2<T> & other) {
- x *= other.x;
- y *= other.y;
- return *this;
+Vector2<T> Vector2<T>::operator+(T scalar) const {
+ return {x + scalar, y + scalar};
+}
+
+template <class T>
+Vector2<T> Vector2<T>::operator*(const Vector2<T> & other) const {
+ return {x * other.x, y * other.y};
+}
+
+template <class T>
+Vector2<T> Vector2<T>::operator*(T scalar) const {
+ return {x * scalar, y * scalar};
+}
+
+template <class T>
+Vector2<T> Vector2<T>::operator/(const Vector2<T> & other) const {
+ return {x / other.x, y / other.y};
+}
+
+template <class T>
+Vector2<T> Vector2<T>::operator/(T scalar) const {
+ return {x / scalar, y / scalar};
}
template <class T>
@@ -26,19 +50,67 @@ Vector2<T> & Vector2<T>::operator+=(const Vector2<T> & other) {
}
template <class T>
-Vector2<T> & Vector2<T>::operator+=(double other) {
+Vector2<T> & Vector2<T>::operator+=(T other) {
x += other;
y += other;
return *this;
}
template <class T>
-Vector2<T> Vector2<T>::operator-() const { return {-x, -y}; }
+Vector2<T> & Vector2<T>::operator-=(const Vector2<T> & other) {
+ x -= other.x;
+ y -= other.y;
+ return *this;
+}
template <class T>
-bool Vector2<T>::operator==(const Vector2<T> & other) const { return x == other.x && y == other.y; }
+Vector2<T> & Vector2<T>::operator-=(T other) {
+ x -= other;
+ y -= other;
+ return *this;
+}
template <class T>
-bool Vector2<T>::operator!=(const Vector2<T> & other) const { return !(*this == other); }
+Vector2<T> & Vector2<T>::operator*=(const Vector2<T> & other) {
+ x *= other.x;
+ y *= other.y;
+ return *this;
+}
+
+template <class T>
+Vector2<T> & Vector2<T>::operator*=(T other) {
+ x *= other;
+ y *= other;
+ return *this;
+}
+
+template <class T>
+Vector2<T> & Vector2<T>::operator/=(const Vector2<T> & other) {
+ x /= other.x;
+ y /= other.y;
+ return *this;
+}
+
+template <class T>
+Vector2<T> & Vector2<T>::operator/=(T other) {
+ x /= other;
+ y /= other;
+ return *this;
+}
+
+template <class T>
+Vector2<T> Vector2<T>::operator-() const {
+ return {-x, -y};
+}
+
+template <class T>
+bool Vector2<T>::operator==(const Vector2<T> & other) const {
+ return x == other.x && y == other.y;
+}
+
+template <class T>
+bool Vector2<T>::operator!=(const Vector2<T> & other) const {
+ return !(*this == other);
+}
} // namespace crepe