#pragma once #include #include #include #include #include namespace Math { const float Pi = M_PI; inline float Radians(float degrees) { return degrees * (Pi/180.f); } inline float Degrees(float radians) { return radians * (180.f/Pi); } struct NumberRange { float LowerBound; float UpperBound; }; float NormalizeToRange(float input, float fromLower, float fromUpper, float toLower, float toUpper); float NormalizeToRange(float input, const NumberRange& from, const NumberRange& to); // auto rotation_normalized = NormalizeToRange(inp, {0, 360}, {-1, 1}); inline float Lerp(float a, float b, float t); } // Dawsh Linear Algebra Library - Everything you need for 3D math namespace LinearAlgebra { class Vector2; // A type representing a position in a 2-dimensional coordinate space. class Vector3; // A type representing a position in a 3-dimensional coordinate space. class Vector4; // A type representing a position in a 4-dimensional coordinate space. class Angle2D; // Uses x,y components to represent a 2D rotation. class EulerAngle; // Uses pitch,yaw,roll components to represent a 3D orientation. class AxisAngle; // class CoordinateFrame; // class Matrix2x2; class Matrix3x3; class Matrix4x4; class Transform2D; class Transform3D; class Quaternion; using Position = Vector3; } // TODO: Enforce Style Consistency (Function Names use MicroSoft Case) // Note: Josh Linear Algebra Types are designed as Immutable Data Types // x, y, z, w, etc. values should not and can not be set directly. // rather, you just construct a new type and assign it. // This might sound ass-backwards for many object types. // But mathematically, a vector or matrix is defined by it's size, and values. // Changing the value of one axis fundamentally changes the definition of the vector/matrix. // So we enforce this conceptually at code level... // If you're wondering how it remains performant, it only heap-allocates a tiny space (4*n bytes for vectors) (4*n*m bytes for matrices) // Just Trust Me Bro - Josjh #define MUTABLE true // Toggle This For: Ugly math, ugly code, and an ugly genital infection! #if MUTABLE #define IMMUTABLE !MUTABLE #endif namespace LinearAlgebra { }