1 #ifndef __DALI_INTERNAL_MATH_H__
2 #define __DALI_INTERNAL_MATH_H__
5 * Copyright (c) 2016 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.
27 typedef float Vec2[2];
28 typedef float Vec3[3];
29 typedef float Vec4[4];
30 typedef float Mat4[16];
34 * @brief Applies a transformation matrix to a vector
36 * @param[out] result The transformed vector
37 * @param[in] m The transformation matrix
38 * @param[in] v The vector to transform
40 void TransformVector3( Vec3 result, const Mat4 m, const Vec3 v );
43 * @brief Computes the length of a vector3
45 * @param[in] v The vector
46 * @return The lenght of the vector
48 float Length( const Vec3 v );
51 * @brief Transforms 2D vector by the Size3 and stores value in Vec2
53 * @param[out] result Vec2 type to store final value
54 * @param[in] v Vector to transform
55 * @param[in] s Size to transform with
57 void MultiplyVectorBySize( Vec2& result, const Vec2 v, const Size3 s );
60 * @brief Transforms 3D vector by the Size3 and stores value in Vec3
62 * @param[out] result Vec3 type to store final value
63 * @param[in] v Vector to transform
64 * @param[in] s Size to transform with
66 void MultiplyVectorBySize( Vec3& result, const Vec3 v, const Size3 s );
69 * @brief Transforms 4D vector by the Size3 and stores value in Vec4
71 * @param[out] result Vec4 type to store final value
72 * @param[in] v Vector to transform
73 * @param[in] s Size to transform with
75 void MultiplyVectorBySize( Vec4& result, const Vec4 v, const Size3 s );
78 * @brief Multiplies 2D vector by the matrix
80 * @param[out] result Result of the multiplication
81 * @param[in] m Matrix to use
82 * @param[in] v Vector to multiply
84 void MultiplyVectorByMatrix4( Vec2& result, const Mat4 m, const Vec2 v );
87 * @brief Multiplies 3D vector by the matrix
89 * @param[out] result Result of the multiplication
90 * @param[in] m Matrix to use
91 * @param[in] v Vector to multiply
93 void MultiplyVectorByMatrix4( Vec3& result, const Mat4 m, const Vec3 v );
96 * @brief Multiplies 4D vector by the matrix
98 * @param[out] result Result of the multiplication
99 * @param[in] m Matrix to use
100 * @param[in] v Vector to multiply
102 void MultiplyVectorByMatrix4( Vec4& result, const Mat4 m, const Vec4 v );
105 * @brief Multiplies two Mat4 matrices
107 * @param[out] result Result of multiplication
108 * @param[in] lhs Left-hand-side matrix to use
109 * @param[in] rhs Right-hand-side matrix to use
111 void MultiplyMatrices( float* result, const Mat4 lhs, const Mat4 rhs );
114 } // namespace Internal
118 #endif //__DALI_INTERNAL_MATH_H__