8 #define GLM_FORCE_RADIANS
11 #include <glm/glm.hpp>
12 #include <glm/gtc/constants.hpp>
13 #include <glm/gtc/epsilon.hpp>
14 #define GLM_ENABLE_EXPERIMENTAL
15 #include <glm/gtx/compatibility.hpp>
16 #include <glm/gtx/norm.hpp>
22 inline float toRadians (
float degree) {
23 return glm::radians(degree);
26 inline bool isInfinite (
const glm::vec3& vec) {
27 return glm::any(glm::isinf(vec));
30 inline float toDegrees (
float radians) {
31 return glm::degrees(radians);
34 inline glm::vec3 fromRadians(
float radians) {
35 return glm::vec3(glm::cos(radians), 0.0f, glm::sin(radians));
38 inline float angle(
const glm::vec3& v) {
39 const float _angle = glm::atan(v.z, v.x);
43 inline glm::vec3 advance (
const glm::vec3& src,
const glm::vec3& direction,
const float scale) {
44 return src + (scale * direction);
48 inline T clamp(T a, T low, T high) {
49 return glm::clamp(a, low, high);
52 static const glm::vec3 ZERO(0.0f);
53 static const glm::vec3 VEC3_INFINITE(std::numeric_limits<float>::infinity());
55 inline glm::vec3 parse(
const std::string& in) {
61 if (::sscanf_s(in.c_str(),
"%f:%f:%f", &x, &y, &z) != 3) {
63 if (::sscanf(in.c_str(),
"%f:%f:%f", &x, &y, &z) != 3) {
68 return glm::vec3(x, y, z);