From 56aed1b35ffd150c39c0bac4ea9de14b3e043c51 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Tue, 22 May 2018 16:41:31 +0100 Subject: [PATCH] Added clarifications to Matrix & Matrix3 documentation & removed unused debug functions Also corrected how the ostream functions print out Matrix & Matrix3. Change-Id: I6a20b8f6e5de138db29cac7baae1346905310ced --- .../dali-test-suite-utils.cpp | 72 ++++++++++-------- automated-tests/src/dali/utc-Dali-Matrix.cpp | 4 +- automated-tests/src/dali/utc-Dali-Matrix3.cpp | 4 +- .../src/dali/utc-Dali-PropertyValue.cpp | 6 +- dali/integration-api/debug.cpp | 87 +-------------------- dali/integration-api/debug.h | 88 ---------------------- dali/public-api/math/matrix.cpp | 10 +-- dali/public-api/math/matrix.h | 50 ++++++------ dali/public-api/math/matrix3.cpp | 14 ++-- dali/public-api/math/matrix3.h | 31 +++++--- 10 files changed, 106 insertions(+), 260 deletions(-) diff --git a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp index b38428b..cf97813 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -107,14 +107,15 @@ void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, const cha if( !equivalent ) { - fprintf(stderr, "%s, checking\n" - "(%f, %f, %f) (%f, %f, %f)\n" - "(%f, %f, %f) == (%f, %f, %f)\n" - "(%f, %f, %f) (%f, %f, %f)\n", + // Align each float to 1234.67, i.e. 3.6 will be " 3.60" + fprintf( stderr, "%s, checking\n" + "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n" + "%7.2f %7.2f %7.2f == %7.2f %7.2f %7.2f\n" + "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n", location, - m1[0], m1[1], m1[2], m2[0], m2[1], m2[2], - m1[3], m1[4], m1[5], m2[3], m2[4], m2[5], - m1[6], m1[7], m1[8], m2[6], m2[7], m2[8]); + m1[0], m1[3], m1[6], m2[0], m2[3], m2[6], + m1[1], m1[4], m1[7], m2[1], m2[4], m2[7], + m1[2], m1[5], m1[8], m2[2], m2[5], m2[8] ); tet_result(TET_FAIL); throw("TET_FAIL"); @@ -138,14 +139,15 @@ void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, float eps if (!equivalent) { - fprintf(stderr, "%s, checking\n" - "(%f, %f, %f) (%f, %f, %f)\n" - "(%f, %f, %f) == (%f, %f, %f)\n" - "(%f, %f, %f) (%f, %f, %f)\n", + // Align each float to 1234.67, i.e. 3.6 will be " 3.60" + fprintf( stderr, "%s, checking\n" + "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n" + "%7.2f %7.2f %7.2f == %7.2f %7.2f %7.2f\n" + "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n", location, - m1[0], m1[1], m1[2], m2[0], m2[1], m2[2], - m1[3], m1[4], m1[5], m2[3], m2[4], m2[5], - m1[6], m1[7], m1[8], m2[6], m2[7], m2[8]); + m1[0], m1[3], m1[6], m2[0], m2[3], m2[6], + m1[1], m1[4], m1[7], m2[1], m2[4], m2[7], + m1[2], m1[5], m1[8], m2[2], m2[5], m2[8] ); tet_result(TET_FAIL); throw("TET_FAIL"); @@ -174,15 +176,17 @@ void DALI_TEST_EQUALS( const Matrix& matrix1, const Matrix& matrix2, const char* if (!identical) { - fprintf(stderr, "%s, checking\n" - "(%f, %f, %f, %f) (%f, %f, %f, %f)\n" - "(%f, %f, %f, %f) == (%f, %f, %f, %f)\n" - "(%f, %f, %f, %f) (%f, %f, %f, %f)\n" - "(%f, %f, %f, %f) (%f, %f, %f, %f)\n", location, - m1[0], m1[1], m1[2], m1[3], m2[0], m2[1], m2[2], m2[3], - m1[4], m1[5], m1[6], m1[7], m2[4], m2[5], m2[6], m2[7], - m1[8], m1[9], m1[10], m1[11], m2[8], m2[9], m2[10], m2[11], - m1[12], m1[13], m1[14], m1[15], m2[12], m2[13], m2[14], m2[15]); + // Align each float to 1234.67, i.e. 3.6 will be " 3.60" + fprintf( stderr, "%s, checking\n" + "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n" + "%7.2f %7.2f %7.2f %7.2f == %7.2f %7.2f %7.2f %7.2f\n" + "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n" + "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n", + location, + m1[0], m1[4], m1[8], m1[12], m2[0], m2[4], m2[8], m2[12], + m1[1], m1[5], m1[9], m1[13], m2[1], m2[5], m2[9], m2[13], + m1[2], m1[6], m1[10], m1[14], m2[2], m2[6], m2[10], m2[14], + m1[3], m1[7], m1[11], m1[15], m2[3], m2[7], m2[11], m2[15] ); tet_result(TET_FAIL); throw("TET_FAIL"); @@ -206,15 +210,17 @@ void DALI_TEST_EQUALS( const Matrix& matrix1, const Matrix& matrix2, float epsil if (!equivalent) { - fprintf(stderr, "%s, checking\n" - "(%f, %f, %f, %f) (%f, %f, %f, %f)\n" - "(%f, %f, %f, %f) == (%f, %f, %f, %f)\n" - "(%f, %f, %f, %f) (%f, %f, %f, %f)\n" - "(%f, %f, %f, %f) (%f, %f, %f, %f)\n", location, - m1[0], m1[1], m1[2], m1[3], m2[0], m2[1], m2[2], m2[3], - m1[4], m1[5], m1[6], m1[7], m2[4], m2[5], m2[6], m2[7], - m1[8], m1[9], m1[10], m1[11], m2[8], m2[9], m2[10], m2[11], - m1[12], m1[13], m1[14], m1[15], m2[12], m2[13], m2[14], m2[15]); + // Align each float to 1234.67, i.e. 3.6 will be " 3.60" + fprintf( stderr, "%s, checking\n" + "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n" + "%7.2f %7.2f %7.2f %7.2f == %7.2f %7.2f %7.2f %7.2f\n" + "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n" + "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n", + location, + m1[0], m1[4], m1[8], m1[12], m2[0], m2[4], m2[8], m2[12], + m1[1], m1[5], m1[9], m1[13], m2[1], m2[5], m2[9], m2[13], + m1[2], m1[6], m1[10], m1[14], m2[2], m2[6], m2[10], m2[14], + m1[3], m1[7], m1[11], m1[15], m2[3], m2[7], m2[11], m2[15] ); tet_result(TET_FAIL); throw("TET_FAIL"); diff --git a/automated-tests/src/dali/utc-Dali-Matrix.cpp b/automated-tests/src/dali/utc-Dali-Matrix.cpp index cd2525f..2bcdc8f 100644 --- a/automated-tests/src/dali/utc-Dali-Matrix.cpp +++ b/automated-tests/src/dali/utc-Dali-Matrix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -795,7 +795,7 @@ int UtcDaliMatrixOStreamOperator(void) oss << matrix; - std::string expectedOutput = "[ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] ]"; + 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; diff --git a/automated-tests/src/dali/utc-Dali-Matrix3.cpp b/automated-tests/src/dali/utc-Dali-Matrix3.cpp index c96859d..620e994 100644 --- a/automated-tests/src/dali/utc-Dali-Matrix3.cpp +++ b/automated-tests/src/dali/utc-Dali-Matrix3.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -328,7 +328,7 @@ int UtcDaliMatrix3OStreamOperator(void) oss << matrix; - std::string expectedOutput = "[ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]"; + std::string expectedOutput = "[ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]"; DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION); END_TEST; diff --git a/automated-tests/src/dali/utc-Dali-PropertyValue.cpp b/automated-tests/src/dali/utc-Dali-PropertyValue.cpp index 91b4768..78fbe46 100644 --- a/automated-tests/src/dali/utc-Dali-PropertyValue.cpp +++ b/automated-tests/src/dali/utc-Dali-PropertyValue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -1226,14 +1226,14 @@ int UtcDaliPropertyValueOutputStream(void) value = Property::Value( Matrix3::IDENTITY ); std::ostringstream stream; stream << value; - DALI_TEST_CHECK( stream.str() == "[ [1, 0, 0], [0, 1, 0], [0, 0, 1] ]" ); + DALI_TEST_CHECK( stream.str() == "[ 1, 0, 0, 0, 1, 0, 0, 0, 1 ]" ); } { value = Property::Value( Matrix::IDENTITY ); std::ostringstream stream; stream << value; - DALI_TEST_CHECK( stream.str() == "[ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] ]" ); + DALI_TEST_CHECK( stream.str() == "[ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]" ); } { diff --git a/dali/integration-api/debug.cpp b/dali/integration-api/debug.cpp index 11b5c35..b9b5044 100644 --- a/dali/integration-api/debug.cpp +++ b/dali/integration-api/debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -53,39 +53,6 @@ namespace // unnamed namespace const uint64_t NANOSECONDS_PER_SECOND = 1e+9; -/** - * Generic function to print out any 2-Dimensional array - * @param[in] data pointer to the source data stored as float[rows][cols] - * @param[in] rows number of rows in 2D array - * @param[in] cols number of columns in 2D array - * @param[in] precision - the precision to write the float data. - * @param[in] indent - the indent level to use. - * @return string - the text representation of the 2D array - */ -std::string Array2DToString(const float *data, unsigned int rows, unsigned int cols, size_t precision, size_t indent) -{ - std::ostringstream oss; - - std::ios_base::fmtflags mask = oss.flags(); - mask &= ~std::ios_base::scientific; - mask |= std::ios_base::fixed; - - for(unsigned int rowIdx = 0; rowIdx < rows; rowIdx++) - { - oss << std::setw(indent) << std::setfill(' ') << ' ' << "[ "; - oss << std::setfill(' ') << std::setprecision(precision) << std::right << std::setiosflags(mask); - - for(unsigned int colIdx = 0; colIdx < cols; colIdx++) - { - oss << std::setw(precision + 6) << (*data++) << ' '; - } - - oss << ']' << std::endl; - } - - return oss.str(); -} - } namespace Integration @@ -285,58 +252,6 @@ std::string FormatToString(const char *format, ...) return s; } -std::string ColorToString(const Vector4& color) -{ - std::ostringstream oss; - oss << ""; - return oss.str(); -} - -std::string Vector4ToString(const Vector4& v, size_t precision, size_t indent) -{ - std::ostringstream oss; - oss << std::setw(indent+3) << std::setfill(' ') << std::setprecision(precision) << std::right; - oss << ""; - return oss.str(); -} - -std::string Vector3ToString(const Vector3& v, size_t precision, size_t indent) -{ - std::ostringstream oss; - oss << std::setw(indent+3) << std::setfill(' ') << std::setprecision(precision) << std::right << std::setiosflags(std::ios_base::fixed); - oss << ""; - return oss.str(); -} - -std::string QuaternionToString(const Quaternion& q, size_t precision, size_t indent) -{ - std::ostringstream oss; - - Vector3 axis; - Radian angle; - q.ToAxisAngle(axis, angle); - - oss << std::setw(indent+3) << std::setfill(' ') << std::setprecision(precision) << std::right; - oss << ""; - - return oss.str(); -} - -std::string Matrix3ToString(const Matrix3& m, size_t precision, size_t indent) -{ - return Array2DToString(m.AsFloat(), 3, 3, precision, indent); -} - -std::string MatrixToString(const Matrix& m, size_t precision, size_t indent) -{ - return Array2DToString(m.AsFloat(), 4, 4, precision, indent); -} - void GetNanoseconds( uint64_t& timeInNanoseconds ) { timespec timeSpec; diff --git a/dali/integration-api/debug.h b/dali/integration-api/debug.h index 0bb89d1..ad0abd4 100644 --- a/dali/integration-api/debug.h +++ b/dali/integration-api/debug.h @@ -426,94 +426,6 @@ public: \ #endif /******************************************************************************** - * Helper writers * - ********************************************************************************/ - -/** - * Helper method to translate a color to a string. - * @param[in] color - the color to translate - * @return string - the text representation of the color. - */ -DALI_CORE_API std::string ColorToString(const Vector4& color); - -/** - * Helper method to translate a vector4 to a string. - * @param[in] v - the vector - * @param[in] precision - the precision to write the float data. - * @param[in] indent - the indent level to use. - * @return string - the text representation of the vector. - */ -DALI_CORE_API std::string Vector4ToString(const Vector4& v, size_t precision=3, size_t indent=0); - -/** - * Helper method to translate a vector4 to a string. - * @param[in] v - the vector - * @param[in] precision - the precision to write the float data. - * @param[in] indent - the indent level to use. - * @return string - the text representation of the vector. - */ -DALI_CORE_API std::string Vector3ToString(const Vector3& v, size_t precision=3, size_t indent=0); - -/** - * Helper method to translate a quaternion to a string. - * @param[in] q the quaternion - * @param[in] precision - the precision to write the float data. - * @param[in] indent - the indent level to use. - * @return string - the text representation of the quaternion. - */ -DALI_CORE_API std::string QuaternionToString(const Quaternion& q, size_t precision=3, size_t indent=0); - -/** - * Helper method to translate a 3x3 matrix to a string. - * @param[in] m - the matrix - * @param[in] precision - the precision to write the float data. - * @param[in] indent - the indent level to use. - * @return string - the text representation of the vector. - */ -DALI_CORE_API std::string Matrix3ToString(const Matrix3& m, size_t precision=3, size_t indent=0); - -/** - * Helper method to translate a 4x4 matrix to a string. - * @param[in] m - the matrix - * @param[in] precision - the precision to write the float data. - * @param[in] indent - the indent level to use. - * @return string - the text representation of the vector. - */ -DALI_CORE_API std::string MatrixToString(const Matrix& m, size_t precision=3, size_t indent=0); - -#ifdef DEBUG_ENABLED - - -/** - * Filtered write of a matrix - */ -#define DALI_LOG_MATRIX(filter, matrix) DALI_LOG_INFO(filter, Debug::General, MatrixToString(matrix)) - -/** - * Filtered write of a vector - */ -#define DALI_LOG_VECTOR4(filter, vector) DALI_LOG_INFO(filter, Debug::General, Vector4ToString(vector)) - -/** - * Filtered write of a vector - */ -#define DALI_LOG_VECTOR3(filter, vector) DALI_LOG_INFO(filter, Debug::General, Vector3ToString(vector)) - -/** - * Filtered write of a color - */ -#define DALI_LOG_COLOR(filter, color) DALI_LOG_INFO(filter, Debug::General, ColorToString(color)) - -#else - -#define DALI_LOG_MATRIX(filter, matrix) -#define DALI_LOG_VECTOR4(filter,vector) -#define DALI_LOG_VECTOR3(filter,vector) -#define DALI_LOG_COLOR(filter, color) - -#endif - -/******************************************************************************** * Time instrumentation * ********************************************************************************/ diff --git a/dali/public-api/math/matrix.cpp b/dali/public-api/math/matrix.cpp index 67ade79..f21575b 100644 --- a/dali/public-api/math/matrix.cpp +++ b/dali/public-api/math/matrix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -778,10 +778,10 @@ void Matrix::GetTransformComponents(Vector3& position, std::ostream& operator<< (std::ostream& o, const Matrix& matrix) { - return o << "[ [" << matrix.mMatrix[0] << ", " << matrix.mMatrix[1] << ", " << matrix.mMatrix[2] << ", " << matrix.mMatrix[3] << "], " - << "[" << matrix.mMatrix[4] << ", " << matrix.mMatrix[5] << ", " << matrix.mMatrix[6] << ", " << matrix.mMatrix[7] << "], " - << "[" << matrix.mMatrix[8] << ", " << matrix.mMatrix[9] << ", " << matrix.mMatrix[10] << ", " << matrix.mMatrix[11] << "], " - << "[" << matrix.mMatrix[12] << ", " << matrix.mMatrix[13] << ", " << matrix.mMatrix[14] << ", " << matrix.mMatrix[15] << "] ]"; + return o << "[ " << matrix.mMatrix[0] << ", " << matrix.mMatrix[1] << ", " << matrix.mMatrix[2] << ", " << matrix.mMatrix[3] << ", " + << matrix.mMatrix[4] << ", " << matrix.mMatrix[5] << ", " << matrix.mMatrix[6] << ", " << matrix.mMatrix[7] << ", " + << matrix.mMatrix[8] << ", " << matrix.mMatrix[9] << ", " << matrix.mMatrix[10] << ", " << matrix.mMatrix[11] << ", " + << matrix.mMatrix[12] << ", " << matrix.mMatrix[13] << ", " << matrix.mMatrix[14] << ", " << matrix.mMatrix[15] << " ]"; } } // namespace Dali diff --git a/dali/public-api/math/matrix.h b/dali/public-api/math/matrix.h index 9391124..91faed2 100644 --- a/dali/public-api/math/matrix.h +++ b/dali/public-api/math/matrix.h @@ -38,8 +38,22 @@ class Quaternion; /** * @brief The Matrix class represents transformations and projections. * - * It is agnostic w.r.t. row/column major notation - it operates on a flat array. - * Each axis is contiguous in memory, so the x axis corresponds to elements 0, 1, 2 and 3, the y axis corresponds to elements 4, 5, 6, 7, etc. + * The matrix is stored as a flat array and is Column Major, i.e. the storage order is as follows (numbers represent + * indices of array): + * + * @code + * + * 0 4 8 12 + * 1 5 9 13 + * 2 6 10 14 + * 3 7 11 15 + * + * @endcode + * + * Each axis is contiguous in memory, so the x-axis corresponds to elements 0, 1, 2 and 3, the y-axis corresponds to + * elements 4, 5, 6, 7, the z-axis corresponds to elements 12, 13, 14 and 15, and the translation vector corresponds to + * elements 12, 13 and 14. + * * @SINCE_1_0.0 */ class DALI_CORE_API Matrix @@ -71,12 +85,7 @@ public: * The order of the values for a transform matrix is: * * @code - * - * xAxis.x xAxis.y xAxis.z 0.0f - * yAxis.x yAxis.y yAxis.z 0.0f - * zAxis.x zAxis.y zAxis.z 0.0f - * trans.x trans.y trans.z 1.0f - * + * [ xAxis.x, xAxis.y, xAxis.z, 0.0f, yAxis.x, yAxis.y, yAxis.z, 0.0f, zAxis.x, zAxis.y, zAxis.z, 0.0f, trans.x, trans.y, trans.z, 1.0f ] * @endcode * * @SINCE_1_0.0 @@ -259,12 +268,7 @@ public: * The order of the values for a transform matrix is: * * @code - * - * xAxis.x xAxis.y xAxis.z 0.0f - * yAxis.x yAxis.y yAxis.z 0.0f - * zAxis.x zAxis.y zAxis.z 0.0f - * trans.x trans.y trans.z 1.0f - * + * [ xAxis.x, xAxis.y, xAxis.z, 0.0f, yAxis.x, yAxis.y, yAxis.z, 0.0f, zAxis.x, zAxis.y, zAxis.z, 0.0f, trans.x, trans.y, trans.z, 1.0f ] * @endcode * * @SINCE_1_0.0 @@ -279,12 +283,7 @@ public: * The order of the values for a transform matrix is: * * @code - * - * xAxis.x xAxis.y xAxis.z 0.0f - * yAxis.x yAxis.y yAxis.z 0.0f - * zAxis.x zAxis.y zAxis.z 0.0f - * trans.x trans.y trans.z 1.0f - * + * [ xAxis.x, xAxis.y, xAxis.z, 0.0f, yAxis.x, yAxis.y, yAxis.z, 0.0f, zAxis.x, zAxis.y, zAxis.z, 0.0f, trans.x, trans.y, trans.z, 1.0f ] * @endcode * * @SINCE_1_0.0 @@ -297,6 +296,9 @@ public: * @brief Function to multiply two matrices and store the result onto third. * * Use this method in time critical path as it does not require temporaries. + * + * result = rhs * lhs + * * @SINCE_1_0.0 * @param[out] result Result of the multiplication * @param[in] lhs Matrix, this can be same matrix as result @@ -318,9 +320,11 @@ public: /** * @brief The multiplication operator. * + * Returned Vector = This Matrix * rhs + * * @SINCE_1_0.0 - * @param[in] rhs The Matrix to multiply this by - * @return A matrix containing the result + * @param[in] rhs The Vector4 to multiply this by + * @return A Vector4 containing the result */ Vector4 operator*(const Vector4& rhs) const; @@ -408,7 +412,7 @@ private: /** * @brief Prints a matrix. * - * It is printed in memory order, i.e. each printed row is contiguous in memory. + * It is printed in memory order. * @SINCE_1_0.0 * @param[in] o The output stream operator * @param[in] matrix The matrix to print diff --git a/dali/public-api/math/matrix3.cpp b/dali/public-api/math/matrix3.cpp index 3273a31..50f7903 100644 --- a/dali/public-api/math/matrix3.cpp +++ b/dali/public-api/math/matrix3.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -36,9 +36,9 @@ #define S22 8 /* - * S00 S01 S02 - * S10 S11 S12 - * S20 S21 S22 + * S00 S10 S20 + * S01 S11 S21 + * S02 S12 S22 */ namespace @@ -281,9 +281,9 @@ bool Matrix3::operator!=(const Matrix3& rhs) const std::ostream& operator<< (std::ostream& o, const Matrix3& matrix) { - return o << "[ [" << matrix.mElements[0] << ", " << matrix.mElements[1] << ", " << matrix.mElements[2] << "], " - << "[" << matrix.mElements[3] << ", " << matrix.mElements[4] << ", " << matrix.mElements[5] << "], " - << "[" << matrix.mElements[6] << ", " << matrix.mElements[7] << ", " << matrix.mElements[8] << "] ]"; + return o << "[ " << matrix.mElements[0] << ", " << matrix.mElements[1] << ", " << matrix.mElements[2] << ", " + << matrix.mElements[3] << ", " << matrix.mElements[4] << ", " << matrix.mElements[5] << ", " + << matrix.mElements[6] << ", " << matrix.mElements[7] << ", " << matrix.mElements[8] << " ]"; } } // namespace Dali diff --git a/dali/public-api/math/matrix3.h b/dali/public-api/math/matrix3.h index 16b52eb..2c3ee6c 100644 --- a/dali/public-api/math/matrix3.h +++ b/dali/public-api/math/matrix3.h @@ -36,6 +36,20 @@ struct Vector2; /** * @brief A 3x3 matrix. * + * The matrix is stored as a flat array and is Column Major, i.e. the storage order is as follows (numbers represent + * indices of array): + * + * @code + * + * 0 3 6 + * 1 4 7 + * 2 5 8 + * + * @endcode + * + * Each axis is contiguous in memory, so the x-axis corresponds to elements 0, 1 and 2, the y-axis corresponds to + * elements 3, 4 and 5, and the z-axis corresponds to elements 6, 7 and 8. + * * @SINCE_1_0.0 */ class DALI_CORE_API Matrix3 @@ -145,11 +159,7 @@ public: * The order of the values for a matrix is: * * @code - * - * xAxis.x yAxis.x zAxis.x - * xAxis.y yAxis.y zAxis.y - * xAxis.z yAxis.z zAxis.z - * + * [ xAxis.x, xAxis.y, xAxis.z, yAxis.x, yAxis.y, yAxis.z, zAxis.x, zAxis.y, zAxis.z ] * @endcode * * @SINCE_1_0.0 @@ -160,13 +170,10 @@ public: /** * @brief Returns the contents of the matrix as an array of 9 floats. * - * @code - * * The order of the values for a matrix is: - * xAxis.x yAxis.x zAxis.x - * xAxis.y yAxis.y zAxis.y - * xAxis.z yAxis.z zAxis.z * + * @code + * [ xAxis.x, xAxis.y, xAxis.z, yAxis.x, yAxis.y, yAxis.z, zAxis.x, zAxis.y, zAxis.z ] * @endcode * * @SINCE_1_0.0 @@ -194,7 +201,6 @@ public: * * @SINCE_1_0.0 * @param[in] scale The value by which to scale the whole matrix - * */ void Scale(float scale); @@ -224,6 +230,9 @@ public: * @brief Function to multiply two matrices and store the result onto third. * * Use this method in time critical path as it does not require temporaries + * + * result = rhs * lhs + * * @SINCE_1_0.0 * @param[out] result Result of the multiplication * @param[in] lhs Matrix, this can be same matrix as result -- 2.7.4