2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiAnim_TransformMatrix3Df.h
20 * @brief Header file of _TransformMatrix3Df class
22 * This file contains declarations _TransformMatrix3Df class.
25 #ifndef _FUI_ANIM_INTERNAL_TRANSFORM_MATRIX3DF_H_
26 #define _FUI_ANIM_INTERNAL_TRANSFORM_MATRIX3DF_H_
28 #include <FBaseSysLog.h>
29 #include <FGrpFloatMatrix4.h>
31 namespace Tizen { namespace Ui { namespace Animations {
41 class _OSP_EXPORT_ _TransformMatrix3Df
44 _TransformMatrix3Df(void);
45 ~_TransformMatrix3Df(void);
49 bool SetTransformMatrix(const Tizen::Graphics::FloatMatrix4& transformMatrix);
50 Tizen::Graphics::FloatMatrix4 GetTransformMatrix(void) const;
51 Tizen::Graphics::FloatMatrix4 Interpolate(const _TransformMatrix3Df& transformMatrixFrom, float progress) const;
53 void UpdateRotationFromEulerAngles(float x, float y, float z);
55 void GetEulerAngles(float& x, float& y, float& z) const;
56 void GetQuaternion(float& x, float& y, float& z, float& w) const;
57 void GetRotationAnchor(float& x, float& y, float& z) const;
58 void SetRotationAnchor(float x, float y, float z);
59 void GetScaleFactors(float& x, float& y, float& z) const;
60 void SetScaleFactors(float x, float y, float z);
61 void GetScaleAnchor(float& x, float& y, float& z) const;
62 void SetScaleAnchor(float x, float y, float z);
63 void GetShearFactors(float& xy, float& xz, float& yz) const;
64 void SetShearFactors(float xy, float xz, float yz);
65 void GetTranslationFactors(float& x, float& y, float& z) const;
66 void SetTranslationFactors(float x, float y, float z);
67 void GetPerspectiveFactors(float& x, float& y, float& z, float& w) const;
68 void SetPerspectiveFactors(float x, float y, float z, float w);
70 Matrix4Type GetMatrixType(void) const
72 return __transformType;
80 : x(0.0f), y(0.0f), z(0.0f)
84 float GetSquaredLength(void) const
86 return ((x * x) + (y * y) + (z * z));
89 float GetLength(void) const
91 return (sqrtf(GetSquaredLength()));
94 void Scale(float newLength)
96 float length = GetLength();
100 x *= newLength / length;
101 y *= newLength / length;
102 z *= newLength / length;
106 float Dot(const Vector3Df& vector3D) const
108 return ((x * vector3D.x) + (y * vector3D.y) + (z * vector3D.z));
111 Vector3Df Cross(const Vector3Df& vector3D) const
114 cross.x = (y * vector3D.z) - (z * vector3D.y);
115 cross.y = (z * vector3D.x) - (x * vector3D.z);
116 cross.z = (x * vector3D.y) - (y * vector3D.x);
120 static void Combine(Vector3Df& result, const Vector3Df& a, const Vector3Df& b, float ascl, float bscl)
122 result.x = (ascl * a.x) + (bscl * b.x);
123 result.y = (ascl * a.y) + (bscl * b.y);
124 result.z = (ascl * a.z) + (bscl * b.z);
136 : x(0.0f), y(0.0f), z(0.0f), w(0.0f)
140 Vector4Df Transform(const Tizen::Graphics::FloatMatrix4& m) const
142 Vector4Df outputVector;
145 outputVector.x = (pin.x * m.Get(0, 0)) + (pin.y * m.Get(1, 0)) + (pin.z * m.Get(2, 0)) + (pin.w * m.Get(3, 0));
146 outputVector.y = (pin.x * m.Get(0, 1)) + (pin.y * m.Get(1, 1)) + (pin.z * m.Get(2, 1)) + (pin.w * m.Get(3, 1));
147 outputVector.z = (pin.x * m.Get(0, 2)) + (pin.y * m.Get(1, 2)) + (pin.z * m.Get(2, 2)) + (pin.w * m.Get(3, 2));
148 outputVector.w = (pin.x * m.Get(0, 3)) + (pin.y * m.Get(1, 3)) + (pin.z * m.Get(2, 3)) + (pin.w * m.Get(3, 3));
151 outputVector.x = (x * m.matrix[0][0]) + (y * m.matrix[0][1]) + (z * m.matrix[0][2]) + (w * m.matrix[0][3]);
152 outputVector.y = (x * m.matrix[1][0]) + (y * m.matrix[1][1]) + (z * m.matrix[1][2]) + (w * m.matrix[1][3]);
153 outputVector.z = (x * m.matrix[2][0]) + (y * m.matrix[2][1]) + (z * m.matrix[2][2]) + (w * m.matrix[2][3]);
154 outputVector.w = (x * m.matrix[3][0]) + (y * m.matrix[3][1]) + (z * m.matrix[3][2]) + (w * m.matrix[3][3]);
163 void DoSlerp(float* result, const float* src1, const float* src2, float t) const;
165 void CalcEulerAngles(void);
168 void V4MulPointByMatrix(const _Vector4Df& pin, const Tizen::Graphics::FloatMatrix4& m, _Vector4Df& pout) const;
169 float V3SquaredLength(const _Vector3Df& v) const;
170 float V3Length(const _Vector3Df& v) const;
171 void V3Scale(_Vector3Df& v, float newlen) const;
172 float V3Dot(const _Vector3Df& a, const _Vector3Df& b) const;
173 void V3Combine(const _Vector3Df& a, const _Vector3Df& b, _Vector3Df& result, float ascl, float bscl) const;
174 void V3Cross(const _Vector3Df& a, const _Vector3Df& b, _Vector3Df& c) const;
177 void UpdateMatrixType(bool fullCheck);
180 Matrix4Type __transformType;
181 bool __usePerspective;
185 bool __useTranslation;
187 float __scaleX, __scaleY, __scaleZ;
188 float __shearXY, __shearXZ, __shearYZ;
189 float __quatX, __quatY, __quatZ, __quatW;
190 float __translationX, __translationY, __translationZ;
191 float __perspectiveX, __perspectiveY, __perspectiveZ, __perspectiveW;
193 float __rotAnchorX, __rotAnchorY, __rotAnchorZ;
194 float __scaleAnchorX, __scaleAnchorY, __scaleAnchorZ;
196 float __rotX, __rotY, __rotZ; // in degree-unit
197 }; // _TransformMatrix3Df
199 }}} // Tizen::Ui::Animations
201 #endif // _FUI_ANIM_INTERNAL_TRANSFORM_MATRIX3DF_H_