diff options
author | Matthew Kosarek <mattkae@protonmail.com> | 2021-07-25 20:20:10 -0400 |
---|---|---|
committer | Matthew Kosarek <mattkae@protonmail.com> | 2021-07-25 20:20:10 -0400 |
commit | 05c4522e5ff424c65aab7cd36c7a15313630ac61 (patch) | |
tree | 4b1f5310029728d46fe3464a500400a2e89fbf13 /shared_cpp/mathlib.h | |
parent | 26d073d768c1a0560fa4358246acd1e308eff7b6 (diff) |
(mkosarek) Fix for wrong timestep
Diffstat (limited to 'shared_cpp/mathlib.h')
-rw-r--r-- | shared_cpp/mathlib.h | 10 |
1 files changed, 8 insertions, 2 deletions
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); |