vectozavr-shooter/engine/Matrix4x4.h

67 lines
1.5 KiB
C
Raw Normal View History

2021-09-13 15:53:43 +03:00
//
// Created by Иван Ильин on 12.01.2021.
//
#ifndef ENGINE_MATRIX4X4_H
#define ENGINE_MATRIX4X4_H
#include <array>
2021-10-31 11:39:08 +03:00
2021-10-28 16:58:02 +03:00
#include "Vec4D.h"
#include "Vec3D.h"
2021-09-13 15:53:43 +03:00
class Matrix4x4 final {
2021-09-13 15:53:43 +03:00
private:
std::array<std::array<double, 4>, 4> _arr{};
2021-09-20 13:54:09 +03:00
2021-09-13 15:53:43 +03:00
public:
2021-10-31 11:39:08 +03:00
Matrix4x4() = default;
Matrix4x4 &operator=(const Matrix4x4 &matrix4X4) = default;
[[nodiscard]] Matrix4x4 operator*(const Matrix4x4 &matrix4X4) const;
2021-09-13 15:53:43 +03:00
2021-10-31 11:39:08 +03:00
[[nodiscard]] Vec4D operator*(const Vec4D &point4D) const;
[[nodiscard]] Vec3D operator*(const Vec3D &vec) const;
2021-09-13 15:53:43 +03:00
2021-10-29 23:44:37 +03:00
[[nodiscard]] Vec3D x() const;
2021-10-31 11:39:08 +03:00
2021-10-29 23:44:37 +03:00
[[nodiscard]] Vec3D y() const;
2021-10-31 11:39:08 +03:00
2021-10-29 23:44:37 +03:00
[[nodiscard]] Vec3D z() const;
2021-10-31 11:39:08 +03:00
[[nodiscard]] Vec3D w() const;
2021-10-29 23:44:37 +03:00
// Any useful matrix (static methods)
2021-09-13 15:53:43 +03:00
Matrix4x4 static Identity();
2021-10-31 11:39:08 +03:00
2021-09-13 15:53:43 +03:00
Matrix4x4 static Zero();
2021-10-31 11:39:08 +03:00
Matrix4x4 static Constant(double value);
Matrix4x4 static Scale(const Vec3D &factor);
Matrix4x4 static Translation(const Vec3D &v);
Matrix4x4 static Rotation(const Vec3D &r);
Matrix4x4 static RotationX(double rx);
Matrix4x4 static RotationY(double ry);
Matrix4x4 static RotationZ(double rz);
Matrix4x4 static Rotation(const Vec3D &v, double rv);
2021-09-13 15:53:43 +03:00
Matrix4x4 static View(const Vec3D &left, const Vec3D &up, const Vec3D &lookAt, const Vec3D &eye);
2021-10-31 11:39:08 +03:00
Matrix4x4 static Projection(double fov = 90.0, double aspect = 1.0, double ZNear = 1.0, double ZFar = 10.0);
Matrix4x4 static ScreenSpace(int width, int height);
2021-09-13 15:53:43 +03:00
};
#endif //INC_3DZAVR_MATRIX4X4_H