/
MathBase.h
56 lines (43 loc) · 1.19 KB
/
MathBase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include <memory>
#include <vector>
#include "glm/glm.hpp"
#include "glm/gtc/quaternion.hpp"
#include "glm/gtx/quaternion.hpp"
#include "glm/gtx/transform.hpp"
#include "glm/gtc/matrix_transform.hpp"
#include "glm/gtx/euler_angles.hpp"
#include "glm/gtx/rotate_vector.hpp"
namespace bmesh {
using glm::vec2;
using glm::vec3;
using glm::vec4;
using glm::mat3;
using glm::mat4;
using glm::quat;
typedef unsigned int uint;
class Angle {
public:
virtual float val() = 0;
};
struct Degrees : public Angle {
float mDegrees;
Degrees(float d) : mDegrees(d) {};
static Degrees fromRadians(float r) { return Degrees(glm::degrees(r)); };
float val() { return mDegrees; }
};
struct Radians : public Angle {
float mRadians;
Radians(float r) : mRadians(r) {};
static Radians fromDegrees(float d) { return Radians(glm::radians(d)); };
float val() { return mRadians; }
};
enum class Primitive {
Lines = 2,
Triangles = 3
};
// vertAng is an angle relative to the vertical y axis (0 - π), horAng is rotation around the y axis (0 - 2π)
inline vec3 getPointOnSphere(float vertAng, float horAng) {
return vec3(sin(vertAng) * cos(horAng), cos(vertAng), sin(vertAng) * sin(horAng));
}
} // namespace bmesh