-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrix.h
57 lines (48 loc) · 1.6 KB
/
Matrix.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
#pragma once
#include "Vector3.h"
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
class Matrix
{
public:
Matrix() { }
Matrix(const Matrix &orig);
void Invert();
void Transpose();
Matrix GetInverse() const;
Matrix GetTranspose() const;
Matrix& operator+=(const Matrix& rhs);
Matrix& operator-=(const Matrix& rhs);
Matrix& operator*=(const Matrix& rhs);
Matrix& operator*=(float rhs);
friend Matrix operator-(const Matrix &lhs, const Matrix &rhs);
friend Matrix operator+(const Matrix &lhs, const Matrix &rhs);
friend Matrix operator*(const Matrix &lhs, const Matrix &rhs);
friend Vector3 operator*(const Matrix &lhs, const Vector3 &rhs);
friend Matrix operator*(const Matrix &lhs, float rhs);
friend Matrix operator*(float lhs, const Matrix &rhs);
friend Vector3 TransformLoc(const Matrix &lhs, const Vector3 &rhs);
friend Vector3 TransformVec(const Matrix &lhs, const Vector3 &rhs);
friend Matrix ZeroMatrix();
friend Matrix IdentityMatrix();
friend Matrix Translate(float x, float y, float z);
friend Matrix Scale(float x, float y, float z);
friend Matrix Rotate(const Vector3 &axis, float angle);
friend Matrix RotateX(float angle);
friend Matrix RotateY(float angle);
friend Matrix RotateZ(float angle);
friend Matrix ViewMatrix(const Vector3 &eye, const Vector3 &gaze, const Vector3 &up);
friend std::ostream& operator<<(std::ostream &out, const Matrix &rhs);
float Determinant();
public:
float mMat[4][4];
};
inline float Det3(
float a, float b, float c,
float d, float e, float f,
float g, float h, float i)
{
return a*e*i + d*h*c + g*b*f - g*e*c - d*b*i - a*h*f;
}