// ---------------------------------------------------------------------------
// 
//   Lily Engine alpha
// 
//   Copyright (c) 2010 Clifford Jolly
//     http://cliffjolly.com
//     cliff@cliffjolly.com
// 
// ---------------------------------------------------------------------------
// 
//   This program is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation; either version 2 of the License, or
//   (at your option) any later version.
//  
//   This program is distributed in the hope that it will be useful, but
//   WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//   General Public License for more details.
// 
//   You should have received a copy of the GNU General Public License
//   along with this program; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
//   USA
// -------------------------- END HEADER -------------------------------------

#ifndef MATRIX_H
#define MATRIX_H

#include <string>

#include "mathdefs.h"
#include "vector3d.h"

class Matrix4x4 {
	public:
		Matrix4x4(void);
		Matrix4x4(VEC_SCALAR *src);
	
		VEC_SCALAR m[16];
		
		inline VEC_SCALAR get(int x, int y) const {
			return m[x + y * 4];
		}
		
		inline void set(int x, int y, VEC_SCALAR value) {
			m[x + y * 4] = value;
		}
	
		Matrix4x4 inverse(void) const;
		Matrix4x4 transpose(void) const;
		Matrix4x4 rotationOnly(void) const;
		Matrix4x4 translationOnly(void) const;
		Matrix4x4 operator+(const Matrix4x4 &mat) const;
		Matrix4x4 operator*(const Matrix4x4 &mat) const;
		Vector3D operator*(const Vector3D &v) const;
	
};

Matrix4x4 translationMatrix(const Vector3D &t);
Matrix4x4 rotationMatrix(const Vector3D &axis, VEC_SCALAR angle);
Matrix4x4 uniformScaleMatrix(VEC_SCALAR s);
Matrix4x4 scaleMatrix(const Vector3D &v);

void debugMatrixPrint(const Matrix4x4 &mat);

#endif
