
function Matrix4x4(){
	this.m = new Array();
	for(var i = 0; i < 4; i++){
		this.m[i] = new Array();
		for(var j = 0; j < 4; j++){
			this.m[i][j] = 0;
			if(j == i){
				this.m[i][j] = 1;
			}
		}
	}
}

Matrix4x4.prototype.mulVec3 = function(vec){
	var newVec = new Vector3(0,0,0);
	var m = this.m;
	newVec.x = m[0][0] * vec.x + m[0][1] * vec.y + m[0][2] * vec.z + m[0][3];
	newVec.x = m[1][0] * vec.x + m[1][1] * vec.y + m[1][2] * vec.z + m[1][3];
	newVec.x = m[2][0] * vec.x + m[2][1] * vec.y + m[2][2] * vec.z + m[2][3];
	
	return newVec;
}

Matrix4x4.prototype.toString = function(){
	var msg = "";
	var m = this.m;
	
	msg += m[0][0] + ", " + m[0][1] + ", " + m[0][2] + ", " + m[0][3] + "\n";
	msg += m[1][0] + ", " + m[1][1] + ", " + m[1][2] + ", " + m[1][3] + "\n";
	msg += m[2][0] + ", " + m[2][1] + ", " + m[2][2] + ", " + m[2][3] + "\n";
	msg += m[3][0] + ", " + m[3][1] + ", " + m[3][2] + ", " + m[3][3] + "\n";
	
	return msg;
}
