feat(Util): Added math::deg_to_rad, math::distance_between_vectors and math::rotation_to_direction
This commit is contained in:
parent
fcfa3094e4
commit
bc5bb861ee
30
BigBaseV2/src/util/math.hpp
Normal file
30
BigBaseV2/src/util/math.hpp
Normal 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)
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user