/*
- * 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.
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");
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");
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");
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");
/*
- * 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.
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;
/*
- * 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.
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;
/*
- * 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.
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 ]" );
}
{
/*
- * 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.
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
return s;
}
-std::string ColorToString(const Vector4& color)
-{
- std::ostringstream oss;
- oss << "<R:" << color.r << " G:" << color.g << " B:" << color.b << " A:" << color.a << ">";
- 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 << "<X:" << std::setw(precision+4) << v.x
- << " Y:" << std::setw(precision+4) << v.y
- << " Z:" << std::setw(precision+4) << v.z
- << " W:" << std::setw(precision+4) << v.w << ">";
- 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 << "<X:" << std::setw(precision+4) << v.x
- << " Y:" << std::setw(precision+4) << v.y
- << " Z:" << std::setw(precision+4) << v.z << ">";
- 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 << "<A:" << std::setw(precision+4) << Degree( angle ).degree << ", " << Vector3ToString(axis, precision, 0) << ">";
-
- 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;
#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 *
********************************************************************************/
/*
- * 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.
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
/**
* @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
* 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
* 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
* 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
* @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
/**
* @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;
/**
* @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
/*
- * 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.
#define S22 8
/*
- * S00 S01 S02
- * S10 S11 S12
- * S20 S21 S22
+ * S00 S10 S20
+ * S01 S11 S21
+ * S02 S12 S22
*/
namespace
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
/**
* @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
* 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
/**
* @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
*
* @SINCE_1_0.0
* @param[in] scale The value by which to scale the whole matrix
- *
*/
void Scale(float scale);
* @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