2016-09-27 16:23:58 +00:00
|
|
|
#include "util.hpp"
|
|
|
|
|
2016-09-28 09:35:56 +00:00
|
|
|
#include <cmath>
|
2016-09-27 16:23:58 +00:00
|
|
|
#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());
|
|
|
|
}
|
2016-09-28 09:35:56 +00:00
|
|
|
|
|
|
|
float deg2rad(float deg)
|
|
|
|
{
|
|
|
|
return M_PI*deg/180.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
float rad2deg(float rad)
|
|
|
|
{
|
|
|
|
return 180.0 * rad / M_PI;
|
|
|
|
}
|
2016-09-27 16:23:58 +00:00
|
|
|
}
|