-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMathFunctions.cpp
43 lines (36 loc) · 1017 Bytes
/
MathFunctions.cpp
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
/*
* MathFunctions.cpp
*
* Created on: 2014/10/18
* Author: Dimitri Kourkoulis
* http://dimitros.be
* License: BSD 3-Clause License (see LICENSE file)
*/
#include "MathFunctions.hpp"
#include <cmath>
namespace small3d {
glm::mat4x4 rotateX(const float &angle)
{
return glm::mat4x4(1.0f, 0.0f, 0.0f, 0.0f,
0.0f, std::cos(angle), -std::sin(angle), 0.0f,
0.0f, std::sin(angle), std::cos(angle), 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
);
}
glm::mat4x4 rotateY(const float &angle)
{
return glm::mat4x4(std::cos(angle), 0.0f, std::sin(angle), 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
-std::sin(angle), 0.0f, std::cos(angle), 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
);
}
glm::mat4x4 rotateZ(const float &angle)
{
return glm::mat4x4(std::cos(angle), -std::sin(angle), 0.0f, 0.0f,
std::sin(angle), std::cos(angle), 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
);
}
}