
#ifndef SPECTRE_MATH_TRANSFORM_H
#define SPECTRE_MATH_TRANSFORM_H

#include "Vector2.h"
#include "Matrix4.h"

// Class representing a transformation matrix.

class Transform
{
public :

	// Constructors
	Transform();

	Transform(const Matrix4f& matrix);

	Transform(float a00, float a01, float a02,
		  float a10, float a11, float a12,
		  float a20, float a21, float a22);

	// Shorthand for applying translate/rotate/scale.
	// Order of operations:
	//	1. translate
	//	2. rotate
	//	3. scale
	void set(Vector2f translate, float rotate, Vector2f scale);

	void setMatrix(const Matrix4f& matrix);

	// Reset the transformation (Identity matrix).
	void reset();

	// Axis.
	Vector2f getUpVector() const;
	Vector2f getRightVector() const;

	// Translation

	Transform& translate(float x, float y);
	Transform& translate(Vector2f offset);

	// Rotation

	Transform& rotate(float theta);

	// Scale

	Transform& scale(float x, float y);
	Transform& scale(Vector2f offset);
	Transform& scale(float s);

	Transform& multiply(const Transform& other);

	Vector2f transformPoint(float x, float y) const;

	Vector2f transformPoint(const Vector2f& v) const;

	// Get the transformation as a 4x4 matrix.
	Matrix4f& getMatrix();
	const Matrix4f& getMatrix() const;

	Matrix4f getRotationMatrix() const;

	float* getRawMatrix();
	const float* getRawMatrix() const;

protected :
	Matrix4f m_matrix;
};

Transform  operator*(const Transform& a, const Transform& b);
Transform& operator*=(Transform& a, const Transform& b);

Vector2f operator*(const Transform& t, const Vector2f& v);

#endif /* SPECTRE_MATH_TRANSFORM_H */