//// Include all GLM core / GLSL features
#include "./glm/glm.hpp" // vec2, vec3, mat4, radians
//// Include all GLM extensions
#include "./glm/ext.hpp" // perspective, translate, rotate
#include <iostream>
using namespace std;
void coutM4x4(glm::mat4 const&);
void coutVec4(glm::vec4 const& v);
int main(void)
{
    //create a translation matrix
	float tx = 2.0, ty = 3.0, tz = -1.0;
	glm::mat4 T1 =
		glm::mat4(1.0, 0.0, 0.0, 0.0, // note this is the leftmost column, not the top row
			0.0, 1.0, 0.0, 0.0,
			0.0, 0.0, 1.0, 0.0,
			tx, ty, tz, 1.0);
	coutM4x4(T1);
    //set up a rotation angle and find sin and cos of it.
	float thetaRadians = glm::radians(90.0);
	float sinTheta = glm::sin(thetaRadians);
	float cosTheta = glm::cos(thetaRadians);
//create a rotation matrix
	glm::mat4 R1 =
	glm::mat4(cosTheta, sinTheta, 0.0, 0.0, // note this is the leftmost column, not the top row
			-sinTheta, -cosTheta, 0.0, 0.0,
			0.0, 0.0, 1.0, 0.0,
			0.0, 0.0, 0.0, 1.0);

    // create a model matrix for concatination of transforms
	glm::mat4 M(1.0); //initialize to the identity matrix, I
    M = T1*R1*M;   //we can multiply matrices M=R*T
	//set up a vertex for translation
	glm::vec4 v = glm::vec4(4.0f,3.0f,1.0f, 1.0f);
		
	cout << "vertex, v is "<<endl;
	coutVec4(v);
	glm::vec4 v1 = M * v; //local space to world space

	cout << "transformed vertex, v1 is ";
	cout << "(" << v1.x << "," << v1.y << "," << v1.z << "," << v1.w << ")" << endl;

	//So you know glm's extended library has transformations included
	glm::vec3 tpos(2.0,3.0,-1.0);
	//set them up like this:-
	M = glm::translate(
		glm::mat4(1.0f), tpos);
	glm::vec4 TransformedPosition = M * v;
	cout << "transformed position is ";
	cout << "(" << TransformedPosition.x << "," << TransformedPosition.y << "," << TransformedPosition.z << "," << TransformedPosition.w << ")" << endl;

	return 0;
}
void coutVec4(glm::vec4 const& v)
{
	for (int j = 0; j < 4; j++)
	{
		cout << v[j] << "\t";
	    cout << endl;	
	}

}
void coutM4x4(glm::mat4 const& T)
{
	for (int i = 0; i < 4; i++)
	{
		for(int j = 0;j<4; j++)
		{
			cout << T[j][i] << "\t";
		}
		cout << endl;
	}
}
