KlassischeKeplerKriege/game/util.cpp

37 lines
608 B
C++
Raw Normal View History

#include "util.hpp"
#include <cmath>
#include <cstdlib>
namespace util {
float randf_m1_1()
{
return 2.0f*randf_0_1() - 1.0f;
}
float randf_0_1()
{
return static_cast<float>(static_cast<double>(rand()) / (double) RAND_MAX);
}
glm::vec2 randv2_m1_1()
{
return glm::vec2(randf_m1_1(), randf_m1_1());
}
glm::vec2 randv2_0_1()
{
return glm::vec2(randf_0_1(), randf_0_1());
}
float deg2rad(float deg)
{
return M_PI*deg/180.0;
}
float rad2deg(float rad)
{
return 180.0 * rad / M_PI;
}
}