From 05c4522e5ff424c65aab7cd36c7a15313630ac61 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Sun, 25 Jul 2021 20:20:10 -0400 Subject: (mkosarek) Fix for wrong timestep --- shared_cpp/mathlib.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'shared_cpp/mathlib.h') diff --git a/shared_cpp/mathlib.h b/shared_cpp/mathlib.h index d550e90..e3c6875 100644 --- a/shared_cpp/mathlib.h +++ b/shared_cpp/mathlib.h @@ -18,6 +18,8 @@ #define ABS(x) (x < 0 ? -x : x) #define SIGN(x) (x < 0 ? -1 : 1) #define PI 3.141592653589793238463 +#define DEG_TO_RAD(x) (x * (PI / 180.f)) +#define RAD_TO_DEG(x) (x * (180.f / PI)) struct Vector2 { float x = 0; @@ -58,10 +60,12 @@ struct Vector3 { Vector3 normalize(); Vector3 operator+(const Vector3& v2); + Vector3& operator+=(Vector3 other); Vector3 operator-(const Vector3& v2); Vector3 operator-(); Vector3 operator*(float value); Vector3 operator*(const Vector3& v2); + Vector3 operator/(const Vector3& v2); float operator[](int index); void printDebug(const char* name); @@ -75,7 +79,7 @@ struct Vector4 { Vector4(); Vector4(float value); - Vector4(float inX = 0.f, float inY = 0.f, float inZ = 0.f, float inW = 1.f); + Vector4(float inX, float inY, float inZ, float inW); Vector4 fromColor(float r, float g, float b, float a); Vector4 toNormalizedColor(); @@ -126,10 +130,10 @@ struct Mat4x4 { }; struct Quaternion { + float w = 0; float x = 0; float y = 0; float z = 0; - float w = 0; float operator [](int index); Quaternion operator*(const Quaternion& other) const; @@ -142,3 +146,5 @@ struct Quaternion { float length() const; float dot(const Quaternion& other) const; }; + +Quaternion quaternionFromRotation(Vector3 axis, float angleRadians); -- cgit v1.2.1