Skip to content
Snippets Groups Projects
Mat4.h 808 B
Newer Older
Postea's avatar
Postea committed
#pragma once

Yoel's avatar
Yoel committed
#include <array>

#include "Vec3.h"

Postea's avatar
Postea committed
namespace util {
class Mat4 {
Yoel's avatar
Yoel committed
   public:
	// Constructor
	Mat4(std::array<float, 16> arr);
	Mat4();
	// Operator
	friend std::ostream& operator<<(std::ostream& os, const Mat4& rhs);
	float operator[](std::array<int, 2> i) const;  // int r, int c
	float& operator[](std::array<int, 2> i);       // int r, int c
	Mat4 operator*(const Mat4& rhs) const;
	bool operator==(const Mat4& rhs) const;
	bool operator!=(const Mat4& rhs) const;
	// Methods
	Mat4 transpose() const;
	Vec3 transformDir(Vec3 v) const;
	Vec3 transformPoint(Vec3 v) const;
	Vec3 position() const;
	Mat4 invertFull() const;

   private:
	std::array<float, 16> arr;
Postea's avatar
Postea committed

Mat4 translate(Vec3 xyz);
Mat4 rotate(Vec3 axis, float angle);
Mat4 scale(Vec3 xyz);
Mat4 identity();
Postea's avatar
Postea committed

Yoel's avatar
Yoel committed
}  // namespace util