/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+#include <dali-test-suite-utils.h>
+#include <dali/public-api/dali-core.h>
+#include <stdlib.h>
+
#include <iostream>
#include <sstream>
-#include <stdlib.h>
-#include <dali/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-
using namespace Dali;
-
void utc_dali_matrix_startup(void)
{
test_return_value = TET_UNDEF;
test_return_value = TET_PASS;
}
-
-int UtcDaliMatrixCtor(void)
+int UtcDaliMatrixConstructor01P(void)
{
- // Test initialized startup
- Matrix m1;
-
- float r1[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
- float r2[] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
- Matrix mr1(r1);
- Matrix mr2(r2);
+ // State of memory cannot be guaranteed, so use
+ // a buffer in a known state to check for changes
+ char buffer[sizeof(Matrix)];
- DALI_TEST_EQUALS(m1, mr1, 0.001f, TEST_LOCATION);
+ memset(buffer, 1, sizeof(Matrix));
- // Test uninitialized startup
- // Stack construct a matrix to non zero, then stack construct another matrix over the top of it.
- float r3[] = { 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f};
+ Matrix* m2 = new(&buffer) Matrix(false);
+ bool initialisation_occured = false;
{
- Matrix m3(r3);
- }
- {
- Matrix m2(false);
-
- bool initialised = true;
+ float* els = m2->AsFloat();
+ for(size_t idx = 0; idx < 16; ++idx, ++els)
{
- float* els = m2.AsFloat();
- for(size_t idx=0; idx<16; ++idx, ++els)
- {
- if(*els != 0.0f)
- initialised = false;
- }
+ if(*els == 0.0f)
+ initialisation_occured = true;
}
-
- DALI_TEST_EQUALS(initialised, false, TEST_LOCATION);
}
- Matrix m4(true);
- DALI_TEST_EQUALS(m4, mr1, 0.001f, TEST_LOCATION);
-
- m4 = m4;
- DALI_TEST_EQUALS(m4, mr1, 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(initialisation_occured, false, TEST_LOCATION);
- Matrix m5(false);
- m5.SetIdentity();
- Matrix m6 = m5;
- DALI_TEST_EQUALS(m6, mr2, 0.001f, TEST_LOCATION);
END_TEST;
}
-// OrthoNormalise fixes floating point errors from matrix rotations
-int UtcDaliMatrixOrthoNormalize0(void)
+int UtcDaliMatrixConstructor02P(void)
{
- Matrix m;
- m.SetIdentity();
+ float r[] = {1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f};
+ Matrix m(r);
- for (int i=0;i<1000;++i)
+ float* els = m.AsFloat();
+ float* init = r;
+ bool initialised = true;
+ for(size_t idx = 0; idx < 16; ++idx, ++els, ++init)
{
- float f = i;
- Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f) );
- axis.Normalize();
-
- m.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), Vector3::ZERO );
- m.OrthoNormalize();
+ if(*els != *init)
+ initialised = false;
}
+ DALI_TEST_EQUALS(initialised, true, TEST_LOCATION);
- bool success = true;
- success &= fabsf(m.GetXAxis().Dot(m.GetYAxis())) < 0.001f;
- success &= fabsf(m.GetYAxis().Dot(m.GetXAxis())) < 0.001f;
- success &= fabsf(m.GetZAxis().Dot(m.GetYAxis())) < 0.001f;
-
- success &= fabsf(m.GetXAxis().Length() - 1.0f) < 0.001f;
- success &= fabsf(m.GetYAxis().Length() - 1.0f) < 0.001f;
- success &= fabsf(m.GetZAxis().Length() - 1.0f) < 0.001f;
-
- DALI_TEST_CHECK(success);
END_TEST;
}
-// OrthoNormalize is not flipping the axes and is maintaining the translation
-int UtcDaliMatrixOrthoNormalize1(void)
+int UtcDaliMatrixConstructor03P(void)
{
- for (int i=0;i<1000;++i)
+ float r[] = {1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f};
+
+ Matrix ma(r);
+ Matrix mb(ma);
+
+ float* els = ma.AsFloat();
+ float* init = mb.AsFloat();
+ bool initialised = true;
+ for(size_t idx = 0; idx < 16; ++idx, ++els, ++init)
{
- float f = i;
- Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f));
- axis.Normalize();
- Vector3 center(10.0f, 15.0f, 5.0f);
+ if(*els != *init)
+ initialised = false;
+ }
+ DALI_TEST_EQUALS(initialised, true, TEST_LOCATION);
- Matrix m0;
- m0.SetIdentity();
- m0.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), center );
+ END_TEST;
+}
- Matrix m1(m0);
- m1.OrthoNormalize();
+int UtcDaliMatrixConstructor04P(void)
+{
+ Quaternion q(Quaternion::IDENTITY);
+ Matrix m(q);
+ DALI_TEST_EQUALS(Matrix(Matrix::IDENTITY), m, 0.001, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMatrixCopyConstructor(void)
+{
+ Matrix m0(Matrix::IDENTITY);
+ Matrix m1(m0);
+ DALI_TEST_EQUALS(m1, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
- DALI_TEST_EQUALS(m0.GetXAxis(), m1.GetXAxis(), 0.001f, TEST_LOCATION);
- DALI_TEST_EQUALS(m0.GetYAxis(), m1.GetYAxis(), 0.001f, TEST_LOCATION);
- DALI_TEST_EQUALS(m0.GetZAxis(), m1.GetZAxis(), 0.001f, TEST_LOCATION);
- DALI_TEST_EQUALS(m0.GetTranslation(), m1.GetTranslation(), 0.001f, TEST_LOCATION);
- }
END_TEST;
}
-// Invert works
-int UtcDaliMatrixInvert01(void)
+int UtcDaliMatrixMoveConstructor(void)
{
- // We're going to invert a whole load of different matrices to make sure we don't
- // fail on particular orientations.
- for (int i=0;i<1000;++i)
- {
- float f = i;
- Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f));
- axis.Normalize();
- Vector3 center(f, cosf(f) * 100.0f, cosf(f*0.5f) * 50.0f);
+ Matrix m0(Matrix::IDENTITY);
+ Matrix m1 = std::move(m0);
+ DALI_TEST_EQUALS(m1, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
- Matrix m0;
- m0.SetIdentity();
- m0.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), center );
+ END_TEST;
+}
- Matrix m1(m0);
- m1.Invert();
+int UtcDaliMatrixCopyAssignment(void)
+{
+ Matrix m0(Matrix::IDENTITY);
+ Matrix m1;
+ m1 = m0;
+ DALI_TEST_EQUALS(m1, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
- Matrix m2( false );
- Matrix::Multiply( m2, m0, m1 );
+ END_TEST;
+}
- DALI_TEST_EQUALS(m2, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
+int UtcDaliMatrixMoveAssignment(void)
+{
+ Matrix m0(Matrix::IDENTITY);
+ Matrix m1;
+ m1 = std::move(m0);
+ DALI_TEST_EQUALS(m1, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
- m1.Invert(); // doube invert - should be back to m0
+ END_TEST;
+}
- DALI_TEST_EQUALS(m0, m1, 0.001f, TEST_LOCATION);
- }
+int UtcDaliMatrixAssignP(void)
+{
+ Matrix a(Matrix::IDENTITY);
+ Matrix b = a;
+ DALI_TEST_EQUALS(a, b, 0.001, TEST_LOCATION);
END_TEST;
}
+int UtcDaliMatrixAssign02P(void)
+{
+ Matrix a(Matrix::IDENTITY);
+ a = a; // self assign does the do nothing branch
+ DALI_TEST_EQUALS(Matrix(Matrix::IDENTITY), a, 0.001, TEST_LOCATION);
+ END_TEST;
+}
-int UtcDaliMatrixInvert02(void)
+int UtcDaliMatrixSetIdentityP(void)
{
- Matrix m1 = Matrix::IDENTITY;
- m1.SetXAxis(Vector3(0.0f, 0.0f, 0.0f));
- DALI_TEST_EQUALS(m1.Invert(), false, TEST_LOCATION);
+ float els[] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f};
+ Matrix m(els);
+ m.SetIdentity();
+
+ DALI_TEST_EQUALS(m, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
END_TEST;
}
+int UtcDaliMatrixSetIdentityAndScaleP(void)
+{
+ float els[] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f};
+ Matrix m(els);
+ m.SetIdentityAndScale(Vector3(4.0f, 4.0f, 4.0f));
+
+ float els2[] = {4.0f, 0.0f, 0.0f, 0.0f, 0.0f, 4.0f, 0.0f, 0.0f, 0.0f, 0.0f, 4.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
+ Matrix r(els2);
+
+ DALI_TEST_EQUALS(m, r, 0.001f, TEST_LOCATION);
+ END_TEST;
+}
-// Invert transform works
-int UtcDaliMatrixInvertTransform01(void)
+int UtcDaliMatrixInvertTransformP(void)
{
- for (int i=0;i<1000;++i)
+ for(int i = 0; i < 1000; ++i)
{
- float f = i;
- Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f));
+ float f = i;
+ Vector3 axis(cosf(f * 0.001f), cosf(f * 0.02f), cosf(f * 0.03f));
axis.Normalize();
- Vector3 center(f, cosf(f) * 100.0f, cosf(f*0.5f) * 50.0f);
+ Vector3 center(f, cosf(f) * 100.0f, cosf(f * 0.5f) * 50.0f);
Matrix m0;
m0.SetIdentity();
- m0.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), center );
+ m0.SetTransformComponents(Vector3::ONE, Quaternion(Radian(1.0f), axis), center);
Matrix m1;
m0.InvertTransform(m1);
- Matrix m2( false );
- Matrix::Multiply( m2, m0, m1 );
+ Matrix m2(false);
+ Matrix::Multiply(m2, m0, m1);
DALI_TEST_EQUALS(m2, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
}
END_TEST;
}
-
-// Invert transform works
-int UtcDaliMatrixInvertTransform02(void)
+int UtcDaliMatrixInvertTransformN(void)
{
- std::string exceptionString( "EqualsZero( mMatrix[3] ) && EqualsZero( mMatrix[7] ) && EqualsZero( mMatrix[11] ) && Equals( mMatrix[15], 1.0f" );
+ std::string exceptionString("EqualsZero(mMatrix[3]) && EqualsZero(mMatrix[7]) && EqualsZero(mMatrix[11]) && Equals(mMatrix[15], 1.0f");
try
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
+ float els[] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f};
Matrix m(els);
Matrix it;
m.InvertTransform(it);
tet_result(TET_FAIL);
}
- catch (Dali::DaliException& e)
+ catch(Dali::DaliException& e)
{
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT(e);
+ DALI_TEST_ASSERT(e, exceptionString, TEST_LOCATION);
}
try
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
+ float els[] = {0.0f, 1.0f, 2.0f, 0.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f};
Matrix m(els);
Matrix it;
m.InvertTransform(it);
tet_result(TET_FAIL);
}
- catch (Dali::DaliException& e)
+ catch(Dali::DaliException& e)
{
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT(e);
+ DALI_TEST_ASSERT(e, exceptionString, TEST_LOCATION);
}
try
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
+ float els[] = {0.0f, 1.0f, 2.0f, 0.0f, 4.0f, 5.0f, 6.0f, 0.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f};
Matrix m(els);
Matrix it;
m.InvertTransform(it);
tet_result(TET_FAIL);
}
- catch (Dali::DaliException& e)
+ catch(Dali::DaliException& e)
{
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT(e);
+ DALI_TEST_ASSERT(e, exceptionString, TEST_LOCATION);
}
try
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
+ float els[] = {0.0f, 1.0f, 2.0f, 0.0f, 4.0f, 5.0f, 6.0f, 0.0f, 8.0f, 9.0f, 10.0f, 0.0f, 12.0f, 13.0f, 14.0f, 15.0f};
Matrix m(els);
Matrix it;
m.InvertTransform(it);
tet_result(TET_FAIL);
}
- catch (Dali::DaliException& e)
+ catch(Dali::DaliException& e)
{
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT(e);
+ DALI_TEST_ASSERT(e, exceptionString, TEST_LOCATION);
}
END_TEST;
}
-
-// GetXAxis
-int UtcDaliMatrixGetXAxis(void)
+int UtcDaliMatrixInvert01P(void)
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
- Matrix m(els);
+ // We're going to invert a whole load of different matrices to make sure we don't
+ // fail on particular orientations.
+ for(int i = 0; i < 1000; ++i)
+ {
+ float f = i;
+ Vector3 axis(cosf(f * 0.001f), cosf(f * 0.02f), cosf(f * 0.03f));
+ axis.Normalize();
+ Vector3 center(f, cosf(f) * 100.0f, cosf(f * 0.5f) * 50.0f);
- DALI_TEST_CHECK(m.GetXAxis() == Vector3(0.0f, 1.0f, 2.0f));
- END_TEST;
-}
+ Matrix m0;
+ m0.SetIdentity();
+ m0.SetTransformComponents(Vector3::ONE, Quaternion(Radian(1.0f), axis), center);
-// GetYAxis
-int UtcDaliMatrixGetYAxis(void)
-{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
- Matrix m(els);
+ Matrix m1(m0);
+ m1.Invert();
+
+ Matrix m2(false);
+ Matrix::Multiply(m2, m0, m1);
+
+ DALI_TEST_EQUALS(m2, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
+
+ m1.Invert(); // doube invert - should be back to m0
- DALI_TEST_CHECK(m.GetYAxis() == Vector3(4.0f, 5.0f, 6.0f));
+ DALI_TEST_EQUALS(m0, m1, 0.001f, TEST_LOCATION);
+ }
END_TEST;
}
-// GetZAxis
-int UtcDaliMatrixGetZAxis(void)
+int UtcDaliMatrixInvert02P(void)
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
- Matrix m(els);
-
- DALI_TEST_CHECK(m.GetZAxis() == Vector3(8.0f, 9.0f, 10.0f));
+ Matrix m1 = Matrix::IDENTITY;
+ m1.SetXAxis(Vector3(0.0f, 0.0f, 0.0f));
+ DALI_TEST_EQUALS(m1.Invert(), false, TEST_LOCATION);
END_TEST;
}
-// GetTranslation
-int UtcDaliMatrixGetTranslation(void)
+int UtcDaliMatrixTransposeP(void)
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
- Matrix m(els);
+ float floats[] =
+ {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f};
- DALI_TEST_EQUALS(m.GetTranslation(), Vector4(12.0f, 13.0f, 14.0f, 15.0f), TEST_LOCATION);
+ Matrix m(floats);
+ m.Transpose();
+
+ bool success = true;
+
+ for(int x = 0; x < 4; ++x)
+ {
+ for(int y = 0; y < 4; ++y)
+ {
+ success &= (m.AsFloat()[x + y * 4] == floats[x * 4 + y]);
+ }
+ }
+
+ DALI_TEST_CHECK(success);
END_TEST;
}
-// GetTranslation
-int UtcDaliMatrixGetTranslation3(void)
+int UtcDaliMatrixGetXAxisP(void)
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
+ float els[] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f};
Matrix m(els);
- DALI_TEST_EQUALS(m.GetTranslation3(), Vector3(12.0f, 13.0f, 14.0f), TEST_LOCATION);
+ DALI_TEST_CHECK(m.GetXAxis() == Vector3(0.0f, 1.0f, 2.0f));
END_TEST;
}
-// SetIdentity
-int UtcDaliMatrixSetIdentity(void)
+int UtcDaliMatrixGetYAxisP(void)
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
+ float els[] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f};
Matrix m(els);
- m.SetIdentity();
- DALI_TEST_EQUALS(m, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
+ DALI_TEST_CHECK(m.GetYAxis() == Vector3(4.0f, 5.0f, 6.0f));
END_TEST;
}
-
-int UtcDaliMatrixSetIdentityAndScale(void)
+int UtcDaliMatrixGetZAxisP(void)
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
+ float els[] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f};
Matrix m(els);
- m.SetIdentityAndScale(Vector3(4.0f, 4.0f, 4.0f));
-
- float els2[] = { 4.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 4.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 4.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f };
- Matrix r(els2);
- DALI_TEST_EQUALS(m, r, 0.001f, TEST_LOCATION);
+ DALI_TEST_CHECK(m.GetZAxis() == Vector3(8.0f, 9.0f, 10.0f));
END_TEST;
}
-
-// SetXAxis
-int UtcDaliMatrixSetXAxis(void)
+int UtcDaliMatrixSetXAxisP(void)
{
- Matrix m;
+ Matrix m;
Vector3 v(2.0f, 3.0f, 4.0f);
m.SetXAxis(v);
END_TEST;
}
-// SetYAxis
-int UtcDaliMatrixSetYAxis(void)
+int UtcDaliMatrixSetYAxisP(void)
{
- Matrix m;
+ Matrix m;
Vector3 v(2.0f, 3.0f, 4.0f);
m.SetYAxis(v);
END_TEST;
}
-// SetZAxis
-int UtcDaliMatrixSetZAxis(void)
+int UtcDaliMatrixSetZAxisP(void)
{
- Matrix m;
+ Matrix m;
Vector3 v(2.0f, 3.0f, 4.0f);
m.SetZAxis(v);
END_TEST;
}
-// SetTranslation
-int UtcDaliMatrixSetTranslation(void)
+int UtcDaliMatrixGetTranslationP(void)
{
- Matrix m;
+ float els[] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f};
+ Matrix m(els);
+
+ DALI_TEST_EQUALS(m.GetTranslation(), Vector4(12.0f, 13.0f, 14.0f, 15.0f), TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMatrixGetTranslation3P(void)
+{
+ float els[] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f};
+ Matrix m(els);
+
+ DALI_TEST_EQUALS(m.GetTranslation3(), Vector3(12.0f, 13.0f, 14.0f), TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMatrixGetScale(void)
+{
+ // Create an arbitrary vector
+ for(float x = 0.0f; x <= 2.0f; x += 0.1f)
+ {
+ for(float y = 0.0f; y < 2.0f; y += 0.1f)
+ {
+ for(float z = 0.0f; z < 2.0f; z += 0.1f)
+ {
+ Vector3 vScale(x, y, z);
+
+ for(float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
+ {
+ Vector3 forward(1.0f, 1.3f, 2.0f);
+ forward.Normalize();
+
+ Quaternion rotation1(Radian(Degree(angle)), forward);
+ Vector3 position1(1.0f, 2.0f, 3.0f);
+
+ Matrix m1(false);
+ m1.SetTransformComponents(vScale, rotation1, position1);
+
+ Vector3 scale2 = m1.GetScale();
+
+ DALI_TEST_EQUALS(vScale, scale2, 0.001, TEST_LOCATION);
+ }
+ }
+ }
+ }
+ END_TEST;
+}
+
+int UtcDaliMatrixSetTranslationP(void)
+{
+ Matrix m;
Vector4 v(2.0f, 3.0f, 4.0f, 5.0f);
m.SetTranslation(v);
END_TEST;
}
-// SetTranslation
-int UtcDaliMatrixSetTranslation3(void)
+int UtcDaliMatrixSetTranslation3P(void)
{
- Matrix m;
+ Matrix m;
Vector3 v(2.0f, 3.0f, 4.0f);
m.SetTranslation(v);
END_TEST;
}
-
-
-// Transpose
-int UtcDaliMatrixTranspose(void)
+int UtcDaliMatrixOrthoNormalize0P(void)
{
- float floats[] =
- { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f
- };
+ // OrthoNormalise fixes floating point errors from matrix rotations
+ Matrix m;
+ m.SetIdentity();
- Matrix m(floats);
- m.Transpose();
+ for(int i = 0; i < 1000; ++i)
+ {
+ float f = i;
+ Vector3 axis(cosf(f * 0.001f), cosf(f * 0.02f), cosf(f * 0.03f));
+ axis.Normalize();
+
+ m.SetTransformComponents(Vector3::ONE, Quaternion(Radian(1.0f), axis), Vector3::ZERO);
+ m.OrthoNormalize();
+ }
bool success = true;
+ success &= fabsf(m.GetXAxis().Dot(m.GetYAxis())) < 0.001f;
+ success &= fabsf(m.GetYAxis().Dot(m.GetXAxis())) < 0.001f;
+ success &= fabsf(m.GetZAxis().Dot(m.GetYAxis())) < 0.001f;
- for (int x=0;x<4;++x)
- {
- for (int y=0;y<4;++y)
- {
- success &= (m.AsFloat()[x+y*4] == floats[x*4+y]);
- }
- }
+ success &= fabsf(m.GetXAxis().Length() - 1.0f) < 0.001f;
+ success &= fabsf(m.GetYAxis().Length() - 1.0f) < 0.001f;
+ success &= fabsf(m.GetZAxis().Length() - 1.0f) < 0.001f;
DALI_TEST_CHECK(success);
END_TEST;
}
-int UtcDaliMatrixOStreamOperator(void)
+int UtcDaliMatrixOrthoNormalize1P(void)
{
- std::ostringstream oss;
+ // OrthoNormalize is not flipping the axes and is maintaining the translation
+ for(int i = 0; i < 1000; ++i)
+ {
+ float f = i;
+ Vector3 axis(cosf(f * 0.001f), cosf(f * 0.02f), cosf(f * 0.03f));
+ axis.Normalize();
+ Vector3 center(10.0f, 15.0f, 5.0f);
- Matrix matrix;
- matrix.SetIdentity();
+ Matrix m0;
+ m0.SetIdentity();
+ m0.SetTransformComponents(Vector3::ONE, Quaternion(Radian(1.0f), axis), center);
- oss << matrix;
+ Matrix m1(m0);
+ m1.OrthoNormalize();
- std::string expectedOutput = "[ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] ]";
+ DALI_TEST_EQUALS(m0.GetXAxis(), m1.GetXAxis(), 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(m0.GetYAxis(), m1.GetYAxis(), 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(m0.GetZAxis(), m1.GetZAxis(), 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(m0.GetTranslation(), m1.GetTranslation(), 0.001f, TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcDaliMatrixConstAsFloatP(void)
+{
+ float r[] = {1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f};
+ const Matrix m(r);
+
+ const float* els = m.AsFloat();
+ const float* init = r;
+ bool initialised = true;
+ for(size_t idx = 0; idx < 16; ++idx, ++els, ++init)
+ {
+ if(*els != *init)
+ initialised = false;
+ }
+ DALI_TEST_EQUALS(initialised, true, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliMatrixAsFloatP(void)
+{
+ float r[] = {1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f};
+ Matrix m(r);
+
+ float* els = m.AsFloat();
+ float* init = r;
+ bool initialised = true;
+ for(size_t idx = 0; idx < 16; ++idx, ++els, ++init)
+ {
+ if(*els != *init)
+ initialised = false;
+ }
+ DALI_TEST_EQUALS(initialised, true, TEST_LOCATION);
- DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION);
END_TEST;
}
-int UtcDaliMatrixMultiply(void)
+int UtcDaliMatrixMultiplyP(void)
{
Matrix m1 = Matrix::IDENTITY;
- float els[] = { 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.707f, 0.707f, 0.0f,
- 0.0f, -0.707f, 0.707f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f };
+ float els[] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.707f, 0.707f, 0.0f, 0.0f, -0.707f, 0.707f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
Matrix result(els);
Quaternion q(Radian(Degree(45.0f)), Vector3::XAXIS);
- Matrix m2(false);
+ Matrix m2(false);
Matrix::Multiply(m2, m1, q);
DALI_TEST_EQUALS(m2, result, 0.01f, TEST_LOCATION);
END_TEST;
}
-int UtcDaliMatrixOperatorMultiply01(void)
+int UtcDaliMatrixOperatorMultiply01P(void)
{
Vector4 v1(2.0f, 5.0f, 4.0f, 0.0f);
- float els[] = {2.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 3.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 4.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f };
+ float els[] = {2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 4.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
Matrix m1(els);
Vector4 v2 = m1 * v1;
END_TEST;
}
-int UtcDaliMatrixOperatorMultiply02(void)
+int UtcDaliMatrixOperatorMultiply02P(void)
{
TestApplication application;
- Vector3 position ( 30.f, 40.f, 50.f);
+ Vector3 position(30.f, 40.f, 50.f);
Matrix m1(false);
m1.SetIdentity();
m1.SetTranslation(-position);
Vector4 positionV4(position);
- positionV4.w=1.0f;
+ positionV4.w = 1.0f;
Vector4 output = m1 * positionV4;
output.w = 0.0f;
END_TEST;
}
-int UtcDaliMatrixOperatorEquals(void)
+int UtcDaliMatrixOperatorMultiply03P(void)
{
- Matrix m1 = Matrix::IDENTITY;
+ const float ll[16] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
+ const float rr[16] = {1.0f, 5.0f, 0.0f, 0.0f, 2.0f, 6.0f, 0.0f, 0.0f, 3.0f, 7.0f, 0.0f, 0.0f, 4.0f, 8.0f, 0.0f, 0.0f};
+ Matrix left(ll);
+ Matrix right(rr);
- float els[] = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
- Matrix r2(els);
- DALI_TEST_EQUALS(m1 == r2, true, TEST_LOCATION);
+ const float els[16] = {26.0f, 32.0f, 38.0f, 44.0f, 32.0f, 40.0f, 48.0f, 56.0f, 38.0f, 48.0f, 58.0f, 68.0f, 44.0f, 56.0f, 68.0f, 80.0f};
+ Matrix result(els);
+
+ // Get result by operator*
+ Matrix multResult = left * right;
+ DALI_TEST_EQUALS(multResult, result, 0.01f, TEST_LOCATION);
+
+ // Get result by Multiply API
+ Matrix::Multiply(multResult, right, left);
+ DALI_TEST_EQUALS(multResult, result, 0.01f, TEST_LOCATION);
- float *f = m1.AsFloat();
- for(size_t i=0; i<16; i++)
- {
- f[15-i] = 1.2f;
- DALI_TEST_EQUALS(m1 == r2, false, TEST_LOCATION);
- }
END_TEST;
}
-
-int UtcDaliMatrixOperatorNotEquals(void)
+int UtcDaliMatrixOperatorMultiplyAssign01P(void)
{
- Matrix m1 = Matrix::IDENTITY;
- float els[] = {2.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 3.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 4.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f };
- Matrix r1(els);
+ tet_infoline("Multiplication Assign operator\n");
+ const float ll[16] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 0.0f, 0.0f, 11.0f, 12.0f, 0.0f, 0.0f};
+ const float rr[16] = {1.0f, 5.0f, 9.0f, 10.0f, 2.0f, 6.0f, 11.0f, 12.0f, 3.0f, 7.0f, 0.0f, 0.0f, 4.0f, 8.0f, 0.0f, 0.0f};
+ Matrix left(ll);
+ Matrix right(rr);
+ Matrix copyedLeft(ll);
+
+ const float els[16] = {217.0f, 242.0f, 38.0f, 44.0f, 263.0f, 294.0f, 48.0f, 56.0f, 38.0f, 48.0f, 58.0f, 68.0f, 44.0f, 56.0f, 68.0f, 80.0f};
+ Matrix result(els);
+
+ // Get result by operator*
+ Matrix multResult = left * right;
+ DALI_TEST_EQUALS(multResult, result, 0.01f, TEST_LOCATION);
+
+ // Get result by operator*=
+ left *= right;
+ DALI_TEST_EQUALS(left, result, 0.01f, TEST_LOCATION);
- DALI_TEST_CHECK(m1 != r1);
- DALI_TEST_CHECK(!(m1 != m1));
END_TEST;
}
-int UtcDaliMatrixGetTransformComponents01(void)
+int UtcDaliMatrixOperatorMultiplyAssign02P(void)
{
- Matrix m2(Matrix::IDENTITY.AsFloat());
- Vector3 pos2;
- Vector3 scale2;
- Quaternion q2;
- m2.GetTransformComponents(pos2, q2, scale2);
- DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 0.0f), pos2, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(Vector3(1.0f, 1.0f, 1.0f), scale2, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(Quaternion(), q2, 0.001, TEST_LOCATION);
+ tet_infoline("Multiplication Assign operator with self matrix\n");
+ const float ll[16] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 0.0f, 0.0f, 11.0f, 12.0f, 0.0f, 0.0f};
+ Matrix left(ll);
+ Matrix copyedLeft(ll);
+
+ const float els[16] = {82.0f, 92.0f, 17.0f, 20.0f, 186.0f, 212.0f, 57.0f, 68.0f, 59.0f, 78.0f, 97.0f, 116.0f, 71.0f, 94.0f, 117.0f, 140.0f};
+ Matrix result(els);
+
+ // Get result by operator*
+ Matrix multResult = left * copyedLeft;
+ DALI_TEST_EQUALS(multResult, result, 0.01f, TEST_LOCATION);
+
+ // Get result by operator*=
+ left *= left;
+ DALI_TEST_EQUALS(left, result, 0.01f, TEST_LOCATION);
+
END_TEST;
}
-
-int UtcDaliMatrixGetTransformComponents02(void)
+int UtcDaliMatrixOperatorEqualsP(void)
{
- // Create an arbitrary vector
- for( float x=-1.0f; x<=1.0f; x+=0.1f )
- {
- for( float y=-1.0f; y<1.0f; y+=0.1f )
- {
- for( float z=-1.0f; z<1.0f; z+=0.1f )
- {
- Vector3 vForward(x, y, z);
- vForward.Normalize();
+ Matrix m1 = Matrix::IDENTITY;
- for( float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
- {
- Quaternion rotation1(Radian(Degree(angle)), vForward);
- Vector3 scale1(2.0f, 3.0f, 4.0f);
- Vector3 position1(1.0f, 2.0f, 3.0f);
+ float els[] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
+ Matrix r2(els);
+ DALI_TEST_EQUALS(m1 == r2, true, TEST_LOCATION);
- Matrix m1(false);
- m1.SetTransformComponents(scale1, rotation1, position1);
+ float* f = m1.AsFloat();
+ for(size_t i = 0; i < 16; i++)
+ {
+ f[15 - i] = 1.2f;
+ DALI_TEST_EQUALS(m1 == r2, false, TEST_LOCATION);
+ }
+ END_TEST;
+}
- Vector3 position2;
- Quaternion rotation2;
- Vector3 scale2;
- m1.GetTransformComponents(position2, rotation2, scale2);
+int UtcDaliMatrixOperatorNotEqualsP(void)
+{
+ Matrix m1 = Matrix::IDENTITY;
+ float els[] = {2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 4.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
+ Matrix r1(els);
- DALI_TEST_EQUALS(position1, position2, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(scale1, scale2, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(rotation1, rotation2, 0.001, TEST_LOCATION);
- }
- }
- }
- }
+ DALI_TEST_CHECK(m1 != r1);
+ DALI_TEST_CHECK(!(m1 != m1));
END_TEST;
}
-int UtcDaliMatrixSetTransformComponents01(void)
+int UtcDaliMatrixSetTransformComponents01P(void)
{
// Create an arbitrary vector
- for( float x=-1.0f; x<=1.0f; x+=0.1f )
+ for(float x = -1.0f; x <= 1.0f; x += 0.1f)
{
- for( float y=-1.0f; y<1.0f; y+=0.1f )
+ for(float y = -1.0f; y < 1.0f; y += 0.1f)
{
- for( float z=-1.0f; z<1.0f; z+=0.1f )
+ for(float z = -1.0f; z < 1.0f; z += 0.1f)
{
Vector3 vForward(x, y, z);
vForward.Normalize();
- for( float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
+ for(float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
{
Quaternion rotation1(Radian(Degree(angle)), vForward);
- Matrix m1(rotation1);
- Matrix result1(false);
+ Matrix m1(rotation1);
+ Matrix result1(false);
Vector3 vForward3(vForward.x, vForward.y, vForward.z);
- result1.SetTransformComponents( Vector3::ONE, Quaternion(Radian(Degree(angle)), vForward3), Vector3::ZERO );
+ result1.SetTransformComponents(Vector3::ONE, Quaternion(Radian(Degree(angle)), vForward3), Vector3::ZERO);
DALI_TEST_EQUALS(m1, result1, 0.001, TEST_LOCATION);
END_TEST;
}
-
-int UtcDaliMatrixSetInverseTransformComponent01(void)
+int UtcDaliMatrixSetInverseTransformComponent01P(void)
{
// Create an arbitrary vector
- for( float x=-1.0f; x<=1.0f; x+=0.1f )
+ for(float x = -1.0f; x <= 1.0f; x += 0.1f)
{
- for( float y=-1.0f; y<1.0f; y+=0.1f )
+ for(float y = -1.0f; y < 1.0f; y += 0.1f)
{
- for( float z=-1.0f; z<1.0f; z+=0.1f )
+ for(float z = -1.0f; z < 1.0f; z += 0.1f)
{
Vector3 vForward(x, y, z);
vForward.Normalize();
- for( float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
{
- Quaternion rotation1(Radian(Degree(angle)), vForward);
- Vector3 scale1(2.0f, 3.0f, 4.0f);
- Vector3 position1(1.0f, 2.0f, 3.0f);
+ Quaternion rotation1(Quaternion::IDENTITY); // test no rotation branch
+ Vector3 scale1(2.0f, 3.0f, 4.0f);
+ Vector3 position1(1.0f, 2.0f, 3.0f);
Matrix m1(false);
m1.SetTransformComponents(scale1, rotation1, position1);
END_TEST;
}
-int UtcDaliMatrixSetInverseTransformComponent02(void)
+int UtcDaliMatrixSetInverseTransformComponent02P(void)
{
// Create an arbitrary vector
- for( float x=-1.0f; x<=1.0f; x+=0.1f )
+ for(float x = -1.0f; x <= 1.0f; x += 0.1f)
{
- for( float y=-1.0f; y<1.0f; y+=0.1f )
+ for(float y = -1.0f; y < 1.0f; y += 0.1f)
{
- for( float z=-1.0f; z<1.0f; z+=0.1f )
+ for(float z = -1.0f; z < 1.0f; z += 0.1f)
{
Vector3 vForward(x, y, z);
vForward.Normalize();
- for( float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
+ for(float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
{
Quaternion rotation1(Radian(Degree(angle)), vForward);
- Matrix rotationMatrix(rotation1); // TEST RELIES ON THIS METHOD WORKING!!!
+ Matrix rotationMatrix(rotation1); // TEST RELIES ON THIS METHOD WORKING!!!
Vector3 position1(5.0f, -6.0f, 7.0f);
Matrix m1(false);
- m1.SetTransformComponents( Vector3::ONE, rotation1, position1 );
+ m1.SetTransformComponents(Vector3::ONE, rotation1, position1);
Matrix m2(false);
- m2.SetInverseTransformComponents( rotationMatrix.GetXAxis(),
- rotationMatrix.GetYAxis(),
- rotationMatrix.GetZAxis(),
- position1 );
+ m2.SetInverseTransformComponents(rotationMatrix.GetXAxis(),
+ rotationMatrix.GetYAxis(),
+ rotationMatrix.GetZAxis(),
+ position1);
Matrix result;
Matrix::Multiply(result, m1, m2);
}
END_TEST;
}
+
+int UtcDaliMatrixGetTransformComponents01P(void)
+{
+ Matrix m2(Matrix::IDENTITY.AsFloat());
+ Vector3 pos2;
+ Vector3 scale2;
+ Quaternion q2;
+ m2.GetTransformComponents(pos2, q2, scale2);
+ DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 0.0f), pos2, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(Vector3(1.0f, 1.0f, 1.0f), scale2, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(Quaternion(), q2, 0.001, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMatrixGetTransformComponents02P(void)
+{
+ // Create an arbitrary vector
+ for(float x = -1.0f; x <= 1.0f; x += 0.1f)
+ {
+ for(float y = -1.0f; y < 1.0f; y += 0.1f)
+ {
+ for(float z = -1.0f; z < 1.0f; z += 0.1f)
+ {
+ Vector3 vForward(x, y, z);
+ vForward.Normalize();
+
+ for(float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
+ {
+ Quaternion rotation1(Radian(Degree(angle)), vForward);
+ Vector3 scale1(2.0f, 3.0f, 4.0f);
+ Vector3 position1(1.0f, 2.0f, 3.0f);
+
+ Matrix m1(false);
+ m1.SetTransformComponents(scale1, rotation1, position1);
+
+ Vector3 position2;
+ Quaternion rotation2;
+ Vector3 scale2;
+ m1.GetTransformComponents(position2, rotation2, scale2);
+
+ DALI_TEST_EQUALS(position1, position2, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(scale1, scale2, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(rotation1, rotation2, 0.001, TEST_LOCATION);
+ }
+ }
+ }
+ }
+ END_TEST;
+}
+
+int UtcDaliMatrixGetTransformComponents03P(void)
+{
+ Matrix m2; // zero branch
+ Vector3 pos2;
+ Vector3 scale2;
+ Quaternion q2;
+ m2.GetTransformComponents(pos2, q2, scale2);
+ DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 0.0f), pos2, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 0.0f), scale2, 0.001, TEST_LOCATION);
+ // DALI_TEST_EQUALS(Quaternion(), q2, 0.001, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMatrixOStreamOperator(void)
+{
+ std::ostringstream oss;
+
+ Matrix matrix;
+ matrix.SetIdentity();
+
+ oss << matrix;
+
+ std::string expectedOutput = "[ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]";
+
+ DALI_TEST_EQUALS(oss.str(), expectedOutput, TEST_LOCATION);
+ END_TEST;
+}