diff --git a/BigBaseV2/src/util/math.hpp b/BigBaseV2/src/util/math.hpp new file mode 100644 index 00000000..8f5a3792 --- /dev/null +++ b/BigBaseV2/src/util/math.hpp @@ -0,0 +1,30 @@ +#pragma once + +namespace big::math +{ + inline float deg_to_rad(float deg) + { + double radian = (3.14159265359 / 180) * deg; + return (float)radian; + } + + inline double distance_between_vectors(Vector3 a, Vector3 b) + { + return sqrt(pow((a.x - b.x), 2) + pow((a.y - b.y), 2) + pow((a.z - b.z), 2)); + } + + inline Vector3 rotation_to_direction(Vector3 rotation) + { + float x = deg_to_rad(rotation.x); + float z = deg_to_rad(rotation.z); + + float num = abs(cos(x)); + + return Vector3 + { + -sin(z) * num, + cos(z) * num, + sin(x) + }; + } +} \ No newline at end of file