feat(Util): Added math::deg_to_rad, math::distance_between_vectors and math::rotation_to_direction

This commit is contained in:
Yimura 2021-05-19 15:30:22 +02:00
parent fcfa3094e4
commit bc5bb861ee
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682

View File

@ -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)
};
}
}