[DEBUG] corection of the roation matrix
This commit is contained in:
parent
e6af555b15
commit
0b2050cf68
@ -11,6 +11,22 @@
|
|||||||
#include <etk/DebugInternal.h>
|
#include <etk/DebugInternal.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void etk::Matrix4::Rotate(etk::Vector3D<float>& vect, float angleRad)
|
||||||
|
{
|
||||||
|
etk::Matrix4 tmpMat = etk::matRotate(vect, angleRad);
|
||||||
|
*this *= tmpMat;
|
||||||
|
}
|
||||||
|
|
||||||
|
void etk::Matrix4::Translate(etk::Vector3D<float>& vect)
|
||||||
|
{
|
||||||
|
etk::Matrix4 tmpMat = etk::matScale(vect);
|
||||||
|
*this *= tmpMat;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
etk::Matrix4 etk::matPerspective(float left, float right, float bottom, float top, float nearVal, float farVal)
|
etk::Matrix4 etk::matPerspective(float left, float right, float bottom, float top, float nearVal, float farVal)
|
||||||
{
|
{
|
||||||
etk::Matrix4 tmp;
|
etk::Matrix4 tmp;
|
||||||
@ -44,10 +60,13 @@ etk::Matrix4 etk::matTranslate(etk::Vector3D<float> vect)
|
|||||||
etk::Matrix4 etk::matScale(etk::Vector3D<float> vect)
|
etk::Matrix4 etk::matScale(etk::Vector3D<float> vect)
|
||||||
{
|
{
|
||||||
etk::Matrix4 tmp;
|
etk::Matrix4 tmp;
|
||||||
|
tmp.Scale(vect);
|
||||||
|
/*
|
||||||
// set scale :
|
// set scale :
|
||||||
tmp.m_mat[0] = vect.x;
|
tmp.m_mat[0] = vect.x;
|
||||||
tmp.m_mat[5] = vect.y;
|
tmp.m_mat[5] = vect.y;
|
||||||
tmp.m_mat[10] = vect.z;
|
tmp.m_mat[10] = vect.z;
|
||||||
|
*/
|
||||||
//TK_INFO("Scale :");
|
//TK_INFO("Scale :");
|
||||||
//etk::matrix::Display(tmp);
|
//etk::matrix::Display(tmp);
|
||||||
return tmp;
|
return tmp;
|
||||||
@ -61,7 +80,7 @@ etk::Matrix4 etk::matRotate(etk::Vector3D<float> vect, float angleRad)
|
|||||||
float invVal = 1.0-cosVal;
|
float invVal = 1.0-cosVal;
|
||||||
// set rotation :
|
// set rotation :
|
||||||
tmp.m_mat[0] = vect.x * vect.x * invVal + cosVal;
|
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[1] = vect.x * vect.y * invVal - vect.z * sinVal;
|
||||||
tmp.m_mat[2] = vect.x * vect.z * invVal + vect.y * sinVal;
|
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[4] = vect.y * vect.x * invVal + vect.z * sinVal;
|
||||||
@ -75,7 +94,6 @@ etk::Matrix4 etk::matRotate(etk::Vector3D<float> vect, float angleRad)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float etk::Matrix4::CoFactor(int32_t row, int32_t col) const
|
float etk::Matrix4::CoFactor(int32_t row, int32_t col) const
|
||||||
{
|
{
|
||||||
return ( ( m_mat[((row+1)&3)*4 + ((col+1)&3)] * m_mat[((row+2)&3)*4 + ((col+2)&3)] * m_mat[((row+3)&3)*4 + ((col+3)&3)]
|
return ( ( m_mat[((row+1)&3)*4 + ((col+1)&3)] * m_mat[((row+2)&3)*4 + ((col+2)&3)] * m_mat[((row+3)&3)*4 + ((col+3)&3)]
|
||||||
|
@ -259,15 +259,18 @@ namespace etk
|
|||||||
m_mat[4] = -Sin;
|
m_mat[4] = -Sin;
|
||||||
m_mat[1] = Sin;
|
m_mat[1] = Sin;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @brief Makes a rotation matrix about an arbitrary axis.
|
* @brief Makes a rotation matrix about an arbitrary axis.
|
||||||
* @param[in] vect vector to apply the angle.
|
* @param[in] vect vector to apply the angle.
|
||||||
* @param[in] angleRad angle to apply.
|
* @param[in] angleRad angle to apply.
|
||||||
*/
|
*/
|
||||||
void Rotate(etk::Vector3D<float> vect, float angleRad=0.0);
|
void Rotate(etk::Vector3D<float>& vect, float angleRad=0.0);
|
||||||
#endif
|
/**
|
||||||
|
* @brief Makes a translation of the matrix
|
||||||
|
* @param[in] vect Translation to apply.
|
||||||
|
*/
|
||||||
|
void Translate(etk::Vector3D<float>& vect);
|
||||||
/**
|
/**
|
||||||
* @brief Computes a cofactor. Used for matrix inversion.
|
* @brief Computes a cofactor. Used for matrix inversion.
|
||||||
* @param[in] row Id of raw.
|
* @param[in] row Id of raw.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user