Fireworks Engine  v2.0
Lightweight Sandbox Game Engine using OpenGL for additional Customisation and Quick Prototyping
maths.h
Go to the documentation of this file.
1 #pragma once
2 
3 #if defined(__GNUC__) || defined(__clang__)
4 #define DEPRECATED __attribute__((deprecated))
5 #elif defined(_MSC_VER)
6 #define DEPRECATED __declspec(deprecated)
7 #else
8 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
9 #define DEPRECATED
10 #endif
11 
12 #include "vec2.h"
13 #include "vec3.h"
14 #include "vec4.h"
15 #include "mat4.h"
16 
17 // GLM
18 #include <glm/glm.hpp>
19 #include <glm/gtc/matrix_transform.hpp>
20 #include <glm/gtc/type_ptr.hpp>
21 #include <glm/gtx/string_cast.hpp>
22 
23 namespace fireworks { namespace maths {
24 
25  DEPRECATED inline double toRadians(float degrees) {
26  return (double)degrees * M_PI / 180.0f;
27  }
28 
29  DEPRECATED inline double toDegrees(float radians) {
30  return (double)radians * 180.0f / M_PI;
31  }
32 
33  template <class T>
34  T DEPRECATED inline clamp(T number, T min, T max, T maxX, T minX)
35  {
36  return (max - min) * ((number - minX) / (maxX - minX)) + min;
37  }
38 
39  // FIXME: Only works for non-floating types
40  template <class T>
41  T DEPRECATED inline getRandomValue(T startRange, T endRange)
42  {
43  T var = startRange + (T(rand()) / T(RAND_MAX) * (endRange - startRange));
44  return var;
45  }
46 
47  DEPRECATED static maths::vec3 fromGLMVec3(const glm::vec3& v) { return maths::vec3(v.x, v.y, v.z); }
48  DEPRECATED static maths::vec4 fromGLMVec4(const glm::vec4& v) { return maths::vec4(v.x, v.y, v.z, v.w); }
49  // TODO: Implement this!
50  //DEPRECATED//static maths::vec3 fromGLMat3(const glm::vec3& v) { return maths::vec3(v.x, v.y, v.z); }
51  //DEPRECATED//static maths::vec3 fromGLMat4(const glm::vec3& v) { return maths::vec3(v.x, v.y, v.z); }
52 
53  DEPRECATED static glm::vec3 toGLMVec3(const maths::vec3& v) { return glm::vec3(v.x, v.y, v.z); }
54  DEPRECATED static glm::vec4 toGLMVec4(const maths::vec4& v) { return glm::vec4(v.x, v.y, v.z, v.w); }
55  // TODO: Implement this!
56  //DEPRECATED//static maths::vec3 toGLMat3(const glm::vec3& v) { return maths::vec3(v.x, v.y, v.z); }
57  //DEPRECATED//static maths::vec3 toGLMat4(const glm::vec3& v) { return maths::vec3(v.x, v.y, v.z); }
58 } }
T DEPRECATED getRandomValue(T startRange, T endRange)
Definition: maths.h:41
float y
Definition: vec4.h:9
T DEPRECATED clamp(T number, T min, T max, T maxX, T minX)
Definition: maths.h:34
float z
Definition: vec3.h:11
DEPRECATED double toDegrees(float radians)
Definition: maths.h:29
Definition: audioclip.cpp:3
float y
Definition: vec3.h:11
float z
Definition: vec4.h:9
#define DEPRECATED
Definition: maths.h:9
Definition: vec3.h:9
DEPRECATED double toRadians(float degrees)
Definition: maths.h:25
float x
Definition: vec4.h:9
Definition: Window.h:60
Definition: vec4.h:7
float x
Definition: vec3.h:11
float w
Definition: vec4.h:9