<commit_before>#ifndef MAT4_H_
#define MAT4_H_

#define DEG2RAD 0.0174532925f
#define RAD2DEG 57.2957795f

#include <stdio.h>
#include <math.h>
#include "Vec3.h"
#include "Quat.h"

// TODO: Add a lookat() function

struct Mat4
{
	////////////////
	///   Data   ///
	////////////////

private:

	// Matrix data members should never be accessed directly from outside
	float values[4][4];

	////////////////////////
	///   Constructors   ///
	////////////////////////

public:

	// Default constructor, sets to identity matrix
	Mat4()
	{
		// Column 1
		values[0][0] = 1; values[1][0] = 0; values[2][0] = 0; values[3][0] = 0;
		
		// Column 2
		values[0][1] = 0; values[1][1] = 1; values[2][1] = 0; values[3][1] = 0;
		
		// Column 3
		values[0][2] = 0; values[1][2] = 0; values[2][2] = 1; values[3][2] = 0;
		
		// Column 4
		values[0][3] = 0; values[1][3] = 0; values[2][3] = 0; values[3][3] = 1;
	}

	// Custom constructor
	Mat4(	float aa, float ba, float ca, float da,
			float ab, float bb, float cb, float db,
			float ac, float bc, float cc, float dc,
			float ad, float bd, float cd, float dd )
	{
		values[0][0] = aa; values[1][0] = ba; values[2][0] = ca; values[3][0] = da;
		values[0][1] = ab; values[1][1] = bb; values[2][1] = cb; values[3][1] = db;
		values[0][2] = ac; values[1][2] = bc; values[2][2] = cc; values[3][2] = dc;
		values[0][3] = ad; values[1][3] = bd; values[2][3] = cd; values[3][3] = dd;
	}

	///////////////////
	///   Methods   ///
	///////////////////

	// Returns the inverse of this matrix
	Mat4 inverse()
	{
		Mat4 result;

		// Seriously, fuck this shit, I had to type all this by hand
		// based off http://www.cg.info.hiroshima-cu.ac.jp/~miyazaki/knowledge/teche23.html

		///////////////////
		///  COLUMN 1   ///
		///////////////////

		/// ROW 1
		result.set( 0, 0,
		values[1][1]*values[2][2]*values[3][3] +
		values[2][1]*values[3][2]*values[1][3] +
		values[3][1]*values[1][2]*values[2][3] -
		values[1][1]*values[3][2]*values[2][3] -
		values[2][1]*values[1][2]*values[3][3] -
		values[3][1]*values[2][2]*values[1][3] );

		/// ROW 2
		result.set( 0, 1,
			values[0][1]*values[3][2]*values[2][3] +
			values[2][1]*values[0][2]*values[3][3] +
			values[3][1]*values[2][2]*values[0][3] -
			values[0][1]*values[2][2]*values[3][3] -
			values[2][1]*values[3][2]*values[0][3] -
			values[3][1]*values[0][2]*values[2][3] );
<commit_msg>Update Mat4.h<commit_after>#ifndef MAT4_H_
#define MAT4_H_

#define DEG2RAD 0.0174532925f
#define RAD2DEG 57.2957795f

#include <stdio.h>
#include <math.h>
#include "Vec3.h"
#include "Quat.h"

// TODO: Add a lookat() function

struct Mat4
{
	////////////////
	///   Data   ///
	////////////////

private:

	// Matrix data members should never be accessed directly from outside
	float values[4][4];

	////////////////////////
	///   Constructors   ///
	////////////////////////

public:

	// Default constructor, sets to identity matrix
	Mat4()
	{
		// Column 1
		values[0][0] = 1; values[1][0] = 0; values[2][0] = 0; values[3][0] = 0;
		
		// Column 2
		values[0][1] = 0; values[1][1] = 1; values[2][1] = 0; values[3][1] = 0;
		
		// Column 3
		values[0][2] = 0; values[1][2] = 0; values[2][2] = 1; values[3][2] = 0;
		
		// Column 4
		values[0][3] = 0; values[1][3] = 0; values[2][3] = 0; values[3][3] = 1;
	}

	// Custom constructor
	Mat4(	float aa, float ba, float ca, float da,
			float ab, float bb, float cb, float db,
			float ac, float bc, float cc, float dc,
			float ad, float bd, float cd, float dd )
	{
		values[0][0] = aa; values[1][0] = ba; values[2][0] = ca; values[3][0] = da;
		values[0][1] = ab; values[1][1] = bb; values[2][1] = cb; values[3][1] = db;
		values[0][2] = ac; values[1][2] = bc; values[2][2] = cc; values[3][2] = dc;
		values[0][3] = ad; values[1][3] = bd; values[2][3] = cd; values[3][3] = dd;
	}

	///////////////////
	///   Methods   ///
	///////////////////

	// Returns the inverse of this matrix
	Mat4 inverse()
	{
		Mat4 result;

		// Seriously, fuck this shit, I had to type all this by hand
		// based off http://www.cg.info.hiroshima-cu.ac.jp/~miyazaki/knowledge/teche23.html

		///////////////////
		///  COLUMN 1   ///
		///////////////////

		/// ROW 1
		result.set( 0, 0,
			values[1][1]*values[2][2]*values[3][3] +
			values[2][1]*values[3][2]*values[1][3] +
			values[3][1]*values[1][2]*values[2][3] -
			values[1][1]*values[3][2]*values[2][3] -
			values[2][1]*values[1][2]*values[3][3] -
			values[3][1]*values[2][2]*values[1][3] );

		/// ROW 2
		result.set( 0, 1,
			values[0][1]*values[3][2]*values[2][3] +
			values[2][1]*values[0][2]*values[3][3] +
			values[3][1]*values[2][2]*values[0][3] -
			values[0][1]*values[2][2]*values[3][3] -
			values[2][1]*values[3][2]*values[0][3] -
			values[3][1]*values[0][2]*values[2][3] );

{'fraction_non_alphanumeric': 0.281959629941127, 'fraction_numerical': 0.08305298570227082, 'mean_word_length': 2.557965594614809, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1915739', 'n_tokens_mistral': 2193, 'n_tokens_neox': 1944, 'n_words': 411}