1 #ifndef DALI_INTERNAL_MATRIX_UTILS_H
2 #define DALI_INTERNAL_MATRIX_UTILS_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
34 * @brief Function to convert from Quaternion to Matrix as float16 array form
37 * @param[out] result Result stored float16 array. It must have at least 16 * sizeof(float) bytes.
38 * @param[in] rotation Input Quaternion.
40 void ConvertQuaternion(float*& result, const Dali::Quaternion& rotation);
45 * @copydoc Dali::Matrix::Multiply
47 void Multiply(Dali::Matrix& result, const Dali::Matrix& lhs, const Dali::Matrix& rhs);
50 * @copydoc Dali::Matrix::Multiply
52 void Multiply(Dali::Matrix& result, const Dali::Matrix& lhs, const Dali::Quaternion& rhs);
55 * @brief Function to multiply two transform matrix and store the result onto third.
57 * This API assume that both lhs and rhs are Transform Matrix.
58 * Scale & Rotation only has 3x3 area of matrix, and Translate only has [12,13,14] index.
59 * So, If we make Matrix for use Transform, 3, 7, 11 is always 0.0f, and 15 is always 1.0f.
60 * So we can reduce the number of multiplication.
62 * When we try to calculate WorldMatrix, It will have good efforts.
64 * Use this method in time critical path as it does not require temporaries.
69 * @param[out] result Result of the multiplication
70 * @param[in] lhs Transform Matrix, this cannot be same matrix as result
71 * @param[in] rhs Transform Matrix, this can be same matrix as result
73 void MultiplyTransformMatrix(Dali::Matrix& result, const Dali::Matrix& lhs, const Dali::Matrix& rhs);
76 * @brief Function to multiply projection matrix x transform matrix. and store the result onto third.
78 * This API assume that projection is Projection Matrix which top/bottom/left/right is symmetrical.
80 * Perspective matrix only has 0, 5, 10, 11, 14 (14 is const value, 1.0f).
81 * Orthographic matrix only has 0, 5, 10, 14, 15 (15 is const value, 1.0f).
82 * If window rotated, we use 1, 4 index instead of 0, 5.
83 * If reflect plane used, we use 2, 6 index.
84 * So we only need 10 values to multiplication.
86 * Use this method in time critical path as it does not require temporaries.
88 * result = projection * lhs
91 * @param[out] result Result of the multiplication
92 * @param[in] lhs Transform Matrix, this cannot be same matrix as result
93 * @param[in] projection Projection Matrix, this can be same matrix as result
95 void MultiplyProjectionMatrix(Dali::Matrix& result, const Dali::Matrix& lhs, const Dali::Matrix& projection);
98 * @brief Function to multiply two matrices and store the result onto first one.
100 * result = result * rhs
103 * @note This method might copy data internally.
106 * @param[in,out] result Result of the multiplication
107 * @param[in] rhs Matrix, this can be same matrix as result
109 void MultiplyAssign(Dali::Matrix& result, const Dali::Matrix& rhs);
114 * @copydoc Dali::Matrix3::Multiply
116 void Multiply(Dali::Matrix3& result, const Dali::Matrix3& lhs, const Dali::Matrix3& rhs);
119 * @brief Function to multiply two matrices and store the result onto first one.
121 * result = result * rhs
124 * @note This method might copy data internally.
127 * @param[in,out] result Result of the multiplication
128 * @param[in] rhs Matrix, this can be same matrix as result
130 void MultiplyAssign(Dali::Matrix3& result, const Dali::Matrix3& rhs);
132 } // namespace MatrixUtils
133 } // namespace Internal
136 #endif // DALI_INTERNAL_MATH_UTILS_H