-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC2DMatrix.cpp
More file actions
67 lines (45 loc) · 1.25 KB
/
C2DMatrix.cpp
File metadata and controls
67 lines (45 loc) · 1.25 KB
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
57
58
59
60
61
62
63
64
65
66
#include "C2DMatrix.h"
/////////////////////////////////////////////////////////////////////
//
// Matrix functions
//
/////////////////////////////////////////////////////////////////////
//create an identity matrix
void C2DMatrix::Identity()
{
m_Matrix._11 = 1; m_Matrix._12 = 0; m_Matrix._13 = 0;
m_Matrix._21 = 0; m_Matrix._22 = 1; m_Matrix._23 = 0;
m_Matrix._31 = 0; m_Matrix._32 = 0; m_Matrix._33 = 1;
}
//create a transformation matrix
void C2DMatrix::Translate(double x, double y)
{
S2DMatrix mat;
mat._11 = 1; mat._12 = 0; mat._13 = 0;
mat._21 = 0; mat._22 = 1; mat._23 = 0;
mat._31 = x; mat._32 = y; mat._33 = 1;
//and multiply
S2DMatrixMultiply(mat);
}
//create a scale matrix
void C2DMatrix::Scale(double xScale, double yScale)
{
S2DMatrix mat;
mat._11 = xScale; mat._12 = 0; mat._13 = 0;
mat._21 = 0; mat._22 = yScale; mat._23 = 0;
mat._31 = 0; mat._32 = 0; mat._33 = 1;
//and multiply
S2DMatrixMultiply(mat);
}
//create a rotation matrix
void C2DMatrix::Rotate(double rot)
{
S2DMatrix mat;
double Sin = sin(rot);
double Cos = cos(rot);
mat._11 = Cos; mat._12 = Sin; mat._13 = 0;
mat._21 = -Sin; mat._22 = Cos; mat._23 = 0;
mat._31 = 0; mat._32 = 0;mat._33 = 1;
//and multiply
S2DMatrixMultiply(mat);
}