-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrix4.h
77 lines (64 loc) · 2.33 KB
/
Matrix4.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef _MATRIX4_H_
#define _MATRIX4_H_
#include "Vector3.h"
#include "Vector4.h"
#include <string>
#include <GL/glut.h>
using namespace std;
class Vector3;
class Matrix4
{
public:
double m[4][4]; // matrix elements
// given
Matrix4(); // constructor
void inverse();
// given
// Constructor with 16 parameters to set the values of the matrix
Matrix4(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double);
void Matrix4::setRowMajorMatrix(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double);
void Matrix4::setColMajorMatrix(double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double);
Matrix4(Vector3&, Vector3&, Vector3&, Vector3&, double, double, double, double);
Matrix4(Matrix4&);
double operator() (const int, const int);
// given
// return pointer to matrix elements
double* getPointer(); // given
// 'get(x,y)' function to read any matrix element
double get(int, int);
void set(int, int, float);
// given
// create identity matrix
void identity();
// Multiply (matrix-times-matrix)
Matrix4 multiply(Matrix4&);
// Multiply (matrix-times-vector)
Vector4 multiply(Vector4&);
void invertOrtho();
// Make a rotation matrix about the x axis
void rotateX(double);
void rotateWindowX(double);
// given
// Make a rotation matrix about the y axis
void rotateY(double);
void rotateWindowY(double);
// Make a rotation matrix about the z axis
void rotateZ(double);
void rotateWindowZ(double);
// Make a rotation matrix about an arbitrary (unit) axis
void rotate(double, Vector3&);
Matrix4& rotate(double, float, float, float);
void copyRot(Matrix4*);
// Make a non-uniform scaling matrix
void scale(double, double, double);
// Make a translation matrix
void translate(double, double, double);
// Print the matrix (display all 16 matrix components numerically on the screen in a 4x4 array)
void print();
// Transpose the matrix
void transpose();
static Matrix4 Matrix4::createCameraMatrix(Vector3&, Vector3&, Vector3&);
GLfloat* Matrix4::getGLMatrix();
Matrix4 Matrix4::trackballRotation(int width, int height, int fromX, int fromY, int toX, int toY);
};
#endif