[DEV] update matrix4 interface

This commit is contained in:
Edouard 2012-11-16 23:37:21 +01:00
parent c35e883279
commit 1f9db2550c
2 changed files with 52 additions and 0 deletions

View File

@ -75,6 +75,51 @@ etk::Matrix4 etk::matrix::rotate(float x, float y, float z, float angleRad)
}
etk::Matrix4 etk::matrix::Translate(etk::Vector3D<float> vect)
{
etk::Matrix4 tmp;
// set translation :
tmp.m_mat[3] = vect.x;
tmp.m_mat[7] = vect.y;
tmp.m_mat[11] = vect.z;
//TK_INFO("Translate :");
//etk::matrix::Display(tmp);
return tmp;
}
etk::Matrix4 etk::matrix::Scale(etk::Vector3D<float> vect)
{
etk::Matrix4 tmp;
// set scale :
tmp.m_mat[0] = vect.x;
tmp.m_mat[5] = vect.y;
tmp.m_mat[10] = vect.z;
//TK_INFO("Scale :");
//etk::matrix::Display(tmp);
return tmp;
}
etk::Matrix4 etk::matrix::Rotate(etk::Vector3D<float> vect, float angleRad)
{
etk::Matrix4 tmp;
float cosVal = cos(angleRad);
float sinVal = sin(angleRad);
float invVal = 1.0-cosVal;
// set rotation :
tmp.m_mat[0] = vect.x * vect.x * invVal + cosVal;
tmp.m_mat[1] = vect.x * vect.y * invVal - vect.z * cosVal;
tmp.m_mat[2] = vect.x * vect.z * invVal + vect.y * sinVal;
tmp.m_mat[4] = vect.y * vect.x * invVal + vect.z * sinVal;
tmp.m_mat[5] = vect.y * vect.y * invVal + cosVal;
tmp.m_mat[6] = vect.y * vect.z * invVal - vect.x * sinVal;
tmp.m_mat[8] = vect.z * vect.x * invVal - vect.y * sinVal;
tmp.m_mat[9] = vect.z * vect.y * invVal + vect.x * sinVal;
tmp.m_mat[10] = vect.z * vect.z * invVal + cosVal;
return tmp;
}
void etk::matrix::Display(etk::Matrix4& tmp)
{
TK_INFO("matrix : (" << tmp.m_mat[0] << " , " << tmp.m_mat[1] << " , " << tmp.m_mat[2] << " , " << tmp.m_mat[3] << " , ");

View File

@ -203,9 +203,16 @@ namespace etk {
};
namespace matrix {
Matrix4 Perspective(float left, float right, float bottom, float top, float nearVal, float farVal);
// TODO : DEPRECATED
Matrix4 Translate(float x=0.0, float y=0.0, float z=0.0);
// TODO : DEPRECATED
Matrix4 Scale(float x=1.0, float y=1.0, float z=1.0);
// TODO : DEPRECATED
Matrix4 rotate(float x, float y, float z, float angleRad=0.0);
Matrix4 Translate(etk::Vector3D<float> vect);
Matrix4 Scale(etk::Vector3D<float> vect);
Matrix4 Rotate(etk::Vector3D<float> vect, float angleRad=0.0);
void Display(Matrix4& tmp);
};
};