-
Notifications
You must be signed in to change notification settings - Fork 0
/
transform2D.h
45 lines (36 loc) · 1.01 KB
/
transform2D.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
#pragma once
#include "utils/glm_utils.h"
namespace transform2D
{
// Translate matrix
inline glm::mat3 Translate(float translateX, float translateY)
{
// TODO(student): Implement the translation matrix
return glm::transpose(
glm::mat3(1, 0, translateX,
0, 1, translateY,
0, 0, 1)
);
}
// Scale matrix
inline glm::mat3 Scale(float scaleX, float scaleY)
{
// TODO(student): Implement the scaling matrix
return glm::transpose(
glm::mat3(scaleX, 0, 0,
0, scaleY, 0,
0, 0, 1)
);
}
// Rotate matrix
inline glm::mat3 Rotate(float radians)
{
// TODO(student): Implement the rotation matrix
return glm::transpose(
glm::mat3(glm::cos(radians), -glm::sin(radians), 0,
glm::sin(radians), glm::cos(radians), 0,
0, 0, 1)
);
}
}
#pragma once