summaryrefslogtreecommitdiff
path: root/shared_cpp/mathlib.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'shared_cpp/mathlib.cpp')
-rw-r--r--shared_cpp/mathlib.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/shared_cpp/mathlib.cpp b/shared_cpp/mathlib.cpp
index 5996ba3..c9f2e0d 100644
--- a/shared_cpp/mathlib.cpp
+++ b/shared_cpp/mathlib.cpp
@@ -234,6 +234,20 @@ Vector4::Vector4(float inX, float inY, float inZ, float inW) {
w = inW;
}
+Vector4::Vector4(Vector2& v) {
+ x = v.x;
+ y = v.y;
+ z = 0;
+ w = 1;
+}
+
+Vector4::Vector4(Vector3& v) {
+ x = v.x;
+ y = v.y;
+ z = v.z;
+ w = 1;
+}
+
Vector4 Vector4::fromColor(float r, float g, float b, float a) {
float scale = 1.f / 255.f;
return { r * scale, g * scale, b * scale, a * scale };
@@ -302,6 +316,20 @@ Vector4 lerp(Vector4 start, Vector4 end, float t) {
return (end - start) * t + start;
}
+void Vector4::operator=(const Vector2& v2) {
+ x = v2.x;
+ y = v2.y;
+ z = 0;
+ w = 1;
+}
+
+void Vector4::operator=(const Vector3& v2) {
+ x = v2.x;
+ y = v2.y;
+ z = v2.z;
+ w = 1;
+}
+
Vector4 Vector4::operator+(const Vector4& v2) {
return add(v2);
}