Commit 14a4a07e authored by cutealien's avatar cutealien

Add documentation and some compile-tests for matrix.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4231 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 238f3b7b
...@@ -225,6 +225,8 @@ namespace core ...@@ -225,6 +225,8 @@ namespace core
//! An alternate transform vector method, writing into an array of 4 floats //! An alternate transform vector method, writing into an array of 4 floats
void transformVect(T *out,const core::vector3df &in) const; void transformVect(T *out,const core::vector3df &in) const;
//! An alternate transform vector method, reading from and writing to an array of 3 floats
void transformVec3(T *out, const T * in) const; void transformVec3(T *out, const T * in) const;
//! Translate a vector by the translation part of this matrix. //! Translate a vector by the translation part of this matrix.
......
...@@ -236,11 +236,108 @@ bool isOrthogonal(void) ...@@ -236,11 +236,108 @@ bool isOrthogonal(void)
return true; return true;
} }
// just calling each function once to find compile problems
void calltest()
{
matrix4 mat;
matrix4 mat2(mat);
f32& f1 = mat(0,0);
const f32& f2 = mat(0,0);
f32& f3 = mat[0];
const f32& f4 = mat[0];
mat = mat;
mat = 1.f;
const f32 * pf1 = mat.pointer();
f32 * pf2 = mat.pointer();
bool b = mat == mat2;
b = mat != mat2;
mat = mat + mat2;
mat += mat2;
mat = mat - mat2;
mat -= mat2;
mat.setbyproduct(mat, mat2);
mat.setbyproduct_nocheck(mat, mat2);
mat = mat * mat2;
mat *= mat2;
mat = mat * 10.f;
mat *= 10.f;
mat.makeIdentity();
b = mat.isIdentity();
b = mat.isOrthogonal();
b = mat.isIdentity_integer_base ();
mat.setTranslation(vector3df(1.f, 1.f, 1.f) );
vector3df v1 = mat.getTranslation();
mat.setInverseTranslation(vector3df(1.f, 1.f, 1.f) );
mat.setRotationRadians(vector3df(1.f, 1.f, 1.f) );
mat.setRotationDegrees(vector3df(1.f, 1.f, 1.f) );
vector3df v2 = mat.getRotationDegrees();
mat.setInverseRotationRadians(vector3df(1.f, 1.f, 1.f) );
mat.setInverseRotationDegrees(vector3df(1.f, 1.f, 1.f) );
mat.setRotationAxisRadiansLH(1.f, vector3df(1.f, 1.f, 1.f) );
mat.setRotationAxisRadiansRH(1.f, vector3df(1.f, 1.f, 1.f) );
mat.setScale(vector3df(1.f, 1.f, 1.f) );
mat.setScale(1.f);
vector3df v3 = mat.getScale();
mat.inverseTranslateVect(v1);
mat.inverseRotateVect(v1);
mat.rotateVect(v1);
mat.rotateVect(v1, v2);
f32 fv3[3];
mat.rotateVect(fv3, v1);
mat.transformVect(v1);
mat.transformVect(v1, v1);
f32 fv4[4];
mat.transformVect(fv4, v1);
mat.transformVec3(fv3, fv3);
mat.translateVect(v1);
plane3df p1;
mat.transformPlane(p1);
mat.transformPlane(p1, p1);
aabbox3df bb1;
mat.transformBox(bb1);
mat.transformBoxEx(bb1);
mat.multiplyWith1x4Matrix(fv4);
mat.makeInverse();
b = mat.getInversePrimitive(mat2);
b = mat.getInverse(mat2);
mat.buildProjectionMatrixPerspectiveFovRH(1.f, 1.f, 1.f, 1000.f);
mat.buildProjectionMatrixPerspectiveFovLH(1.f, 1.f, 1.f, 1000.f);
mat.buildProjectionMatrixPerspectiveFovInfinityLH(1.f, 1.f, 1.f);
mat.buildProjectionMatrixPerspectiveRH(100.f, 100.f, 1.f, 1000.f);
mat.buildProjectionMatrixPerspectiveLH(10000.f, 10000.f, 1.f, 1000.f);
mat.buildProjectionMatrixOrthoLH(10000.f, 10000.f, 1.f, 1000.f);
mat.buildProjectionMatrixOrthoRH(10000.f, 10000.f, 1.f, 1000.f);
mat.buildCameraLookAtMatrixLH(vector3df(1.f, 1.f, 1.f), vector3df(0.f, 0.f, 0.f), vector3df(0.f, 1.f, 0.f) );
mat.buildCameraLookAtMatrixRH(vector3df(1.f, 1.f, 1.f), vector3df(0.f, 0.f, 0.f), vector3df(0.f, 1.f, 0.f) );
mat.buildShadowMatrix(vector3df(1.f, 1.f, 1.f), p1);
core::rect<s32> a1(0,0,100,100);
mat.buildNDCToDCMatrix(a1, 1.f);
mat.interpolate(mat2, 1.f);
mat = mat.getTransposed();
mat.getTransposed(mat2);
mat.buildRotateFromTo(vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f));
mat.setRotationCenter(vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f));
mat.buildAxisAlignedBillboard(vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f));
mat.buildTextureTransform( 1.f,vector2df(1.f, 1.f), vector2df(1.f, 1.f), vector2df(1.f, 1.f));
mat.setTextureRotationCenter( 1.f );
mat.setTextureTranslate( 1.f, 1.f );
mat.setTextureTranslateTransposed(1.f, 1.f);
mat.setTextureScale( 1.f, 1.f );
mat.setTextureScaleCenter( 1.f, 1.f );
f32 fv16[16];
mat.setM(fv16);
mat.setDefinitelyIdentityMatrix(false);
b = mat.getDefinitelyIdentityMatrix();
b = mat.equals(mat2);
f1 = f1+f2+f3+f4+*pf1+*pf2; // getting rid of unused variable warnings.
}
} }
bool matrixOps(void) bool matrixOps(void)
{ {
bool result = true; bool result = true;
calltest();
result &= identity(); result &= identity();
result &= rotations(); result &= rotations();
result &= isOrthogonal(); result &= isOrthogonal();
......
Tests finished. 1 test of 1 passed. Tests finished. 1 test of 1 passed.
Compiled as DEBUG Compiled as DEBUG
Test suite pass at GMT Sat Jul 7 09:09:13 2012 Test suite pass at GMT Sat Jul 7 10:28:50 2012
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment