Clementine
Matrix4.h
1 // Copyright 2021 SMS
2 // License(Apache-2.0)
3 
4 #pragma once
5 
6 #include <cfloat>
7 #include <cmath>
8 #include <initializer_list>
9 
15 class Vector3;
16 
20 class Matrix4
21 {
22 public:
23  float m[4][4];
24 
25  Matrix4();
26  Matrix4(std::initializer_list<float> list);
27  Matrix4(const float* m);
28 
29  Vector3 getTranslation() const;
30  Vector3 getRotation() const;
31  Vector3 getScale() const;
32 
33  void translate(const Vector3& vec);
34  // void rotate(const Vector3& pivot, float angleX, float angleY, float angleZ);
35  void rotateX(float angle);
36  void rotateY(float angle);
37  void rotateZ(float angle);
38  void scale(const Vector3& vec);
39 
40  Matrix4 operator-() const;
41  Matrix4& operator=(const Matrix4& rhs);
42  Matrix4 operator+(const Matrix4& rhs) const;
43  Matrix4& operator+=(const Matrix4& rhs);
44  Matrix4 operator-(const Matrix4& rhs) const;
45  Matrix4& operator-=(const Matrix4& rhs);
46  Matrix4 operator*(const Matrix4& rhs) const;
47  Matrix4& operator*=(const Matrix4& rhs);
48  Matrix4 operator*(float rhs) const;
49  Matrix4& operator*=(float rhs);
50 
51  static const Matrix4 identity;
52  static const Matrix4 zero;
53 };
54 
55 using Mat4 = Matrix4;
56 
4x4 矩阵, 单精度浮点数.
Definition: Matrix4.h:20
三维向量, 单精度浮点数.
Definition: Vector3.h:17