#pragma once #include #include #include #include #define MAX(x, y) (((x) > (y)) ? (x) : (y)) #define MIN(x, y) (((x) < (y)) ? (x) : (y)) #define ABS(x) (x < 0 ? -x : x) #define SIGN(x) (x < 0 ? -1 : 1) struct Vector2 { float x = 0; float y = 0; Vector2 operator+(Vector2 other); Vector2& operator+=(Vector2 other); Vector2 operator-(Vector2 other); Vector2 operator*(float s); Vector2 operator/(float s); float dot(Vector2 other); float length(); Vector2 normalize(); Vector2 negate(); Vector2 getPerp(); Vector2 rotate(float angle); void printDebug(const char* name); float determinant(Vector2 other); }; struct Vector3 { float x = 0.f; float y = 0.f; float z = 0.f; float length(); Vector3 operator+(const Vector3& other); }; struct Vector4 { float x = 0.f; float y = 0.f; float z = 0.f; float w = 0.f; float length(); Vector4 normalize(); Vector4 fromColor(float r, float g, float b, float a); Vector4 toNormalizedColor(); }; struct Mat4x4 { float m[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; Mat4x4 copy(); Mat4x4 scale(Vector3 v); Mat4x4 translate(Vector3 v); Mat4x4 translateByVec2(Vector2 v); Mat4x4 rotate2D(float angle); Mat4x4 getXRotationMatrix(float angleRadians); Mat4x4 getYRotationMatrix(float angleRadians); Mat4x4 getZRotationMatrix(float angleRadians); Mat4x4 rotate(float xRadians, float yRadians, float zRadians); Vector2 multByVec2(Vector2 v); Vector2 operator*(Vector2 v); Mat4x4 multMat4x4(const Mat4x4& other); Mat4x4 operator*(const Mat4x4& other); Mat4x4 getOrthographicMatrix(float left, float right, float bottom, float top); Mat4x4 inverse(); Mat4x4 getPerspectiveProjection(float near, float far, float fieldOfViewRadians, float aspectRatio); void print(); }; struct Quaternion { float x = 0; float y = 0; float z = 0; float w = 0; float operator [](int index); Quaternion operator*(const Quaternion& other) const; Quaternion operator*(const float& scale) const; Quaternion operator+(const Quaternion& other) const; Quaternion operator-(const Quaternion& other) const; Quaternion interpolate(const Quaternion& other, const float factor); Mat4x4 toMatrix() const; Quaternion normalize() const; float length() const; float dot(const Quaternion& other) const; };