-#ifndef __DALI_MATRIX3_H__
-#define __DALI_MATRIX3_H__
+#ifndef DALI_MATRIX3_H
+#define DALI_MATRIX3_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/math/vector3.h>
-#include <dali/public-api/math/matrix.h>
#include <dali/public-api/common/type-traits.h>
+#include <dali/public-api/math/matrix.h>
+#include <dali/public-api/math/vector3.h>
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
{
public:
-
- friend std::ostream& operator<< (std::ostream& o, const Matrix3& matrix);
+ friend DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Matrix3& matrix);
/**
* @brief The identity matrix.
Matrix3(float s00, float s01, float s02, float s10, float s11, float s12, float s20, float s21, float s22);
/**
+ * @brief Move constructor.
+ *
+ * @SINCE_1_9.21
+ * @param[in] matrix A reference to the moved matrix
+ */
+ Matrix3(Matrix3&& matrix);
+
+ /**
+ * @brief Move assignment operator.
+ *
+ * @SINCE_1_9.21
+ * @param[in] matrix A reference to the moved matrix
+ * @return A reference to this
+ */
+ Matrix3& operator=(Matrix3&& matrix);
+
+ /**
* @brief Assignment Operator.
* @SINCE_1_0.0
* @param[in] matrix From which to copy values
* @return Reference to this object
*/
- Matrix3& operator=( const Matrix3& matrix );
+ Matrix3& operator=(const Matrix3& matrix);
/**
* @brief Assignment Operator.
* @param[in] matrix A reference to the copied matrix
* @return A reference to this
*/
- Matrix3& operator=( const Matrix& matrix );
+ Matrix3& operator=(const Matrix& matrix);
/**
* @brief The equality operator.
* @param[in] rhs The Matrix to compare this to
* @return True if the matrices are equal
*/
- bool operator==(const Matrix3 & rhs) const;
+ bool operator==(const Matrix3& rhs) const;
/**
* @brief The inequality operator.
* @param[in] rhs The Matrix to compare this to
* @return true if the matrices are equal
*/
- bool operator!=(const Matrix3 & rhs) const;
+ bool operator!=(const Matrix3& rhs) const;
/**
* @brief Destructor.
* @SINCE_1_0.0
*/
- ~Matrix3()
- {
- }
+ ~Matrix3() = default;
/**
* @brief Sets the matrix to the identity matrix.
* 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
* @return The matrix contents as an array of 9 floats
*/
- const float* AsFloat() const {return &mElements[0];}
+ const float* AsFloat() const
+ {
+ return &mElements[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
* @return The matrix contents as an array of 9 floats
*/
- float* AsFloat() {return &mElements[0];}
+ float* AsFloat()
+ {
+ return &mElements[0];
+ }
/**
* @brief Inverts the matrix.
*
* @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
* @param[in] rhs Matrix, this cannot be same matrix as result
*/
- static void Multiply( Matrix3& result, const Matrix3& lhs, const Matrix3& rhs );
+ static void Multiply(Matrix3& result, const Matrix3& lhs, const Matrix3& rhs);
private:
-
float mElements[9]; ///< The elements of the matrix
};
* @param[in] matrix The matrix to print
* @return The output stream operator
*/
-DALI_CORE_API std::ostream& operator<< (std::ostream& o, const Matrix3& matrix);
+DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Matrix3& matrix);
// Allow Matrix3 to be treated as a POD type
-template <> struct TypeTraits< Matrix3 > : public BasicTypes< Matrix3 > { enum { IS_TRIVIAL_TYPE = true }; };
+template<>
+struct TypeTraits<Matrix3> : public BasicTypes<Matrix3>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
/**
* @}
*/
} // namespace Dali
-#endif //__DALI_MATRIX3_H__
+#endif //DALI_MATRIX3_H