[NUI] Add license, delete unnecessary code (#2679)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Common / Matrix.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 namespace Tizen.NUI
19 {
20     internal class Matrix : Disposable
21     {
22         internal Matrix(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
23         {
24         }
25
26         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Matrix obj)
27         {
28             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
29         }
30
31         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
32         {
33             Interop.Matrix.DeleteMatrix(swigCPtr);
34         }
35
36
37         public static Vector4 operator *(Matrix arg1, Vector4 arg2)
38         {
39             return arg1.Multiply(arg2);
40         }
41
42         public Matrix() : this(Interop.Matrix.NewMatrix(), true)
43         {
44             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
45         }
46
47         public Matrix(bool initialize) : this(Interop.Matrix.NewMatrix(initialize), true)
48         {
49             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50         }
51
52         public Matrix(float[] array) : this(Interop.Matrix.NewMatrix(array), true)
53         {
54             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
55         }
56
57         public Matrix(Rotation rotation) : this(Interop.Matrix.NewMatrixQuaternion(Rotation.getCPtr(rotation)), true)
58         {
59             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
60         }
61
62         public Matrix(Matrix matrix) : this(Interop.Matrix.NewMatrix(Matrix.getCPtr(matrix)), true)
63         {
64             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
65         }
66
67         public Matrix Assign(Matrix matrix)
68         {
69             Matrix ret = new Matrix(Interop.Matrix.Assign(SwigCPtr, Matrix.getCPtr(matrix)), false);
70             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
71             return ret;
72         }
73
74         public static Matrix IDENTITY
75         {
76             get
77             {
78                 global::System.IntPtr cPtr = Interop.Matrix.IdentityGet();
79                 Matrix ret = (cPtr == global::System.IntPtr.Zero) ? null : new Matrix(cPtr, false);
80                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81                 return ret;
82             }
83         }
84
85         public void SetIdentity()
86         {
87             Interop.Matrix.SetIdentity(SwigCPtr);
88             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89         }
90
91         public void SetIdentityAndScale(Vector3 scale)
92         {
93             Interop.Matrix.SetIdentityAndScale(SwigCPtr, Vector3.getCPtr(scale));
94             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
95         }
96
97         public void InvertTransform(Matrix result)
98         {
99             Interop.Matrix.InvertTransform(SwigCPtr, Matrix.getCPtr(result));
100             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101         }
102
103         public bool Invert()
104         {
105             bool ret = Interop.Matrix.Invert(SwigCPtr);
106             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
107             return ret;
108         }
109
110         public void Transpose()
111         {
112             Interop.Matrix.Transpose(SwigCPtr);
113             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114         }
115
116         public Vector3 GetXAxis()
117         {
118             Vector3 ret = new Vector3(Interop.Matrix.GetXAxis(SwigCPtr), true);
119             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
120             return ret;
121         }
122
123         public Vector3 GetYAxis()
124         {
125             Vector3 ret = new Vector3(Interop.Matrix.GetYAxis(SwigCPtr), true);
126             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127             return ret;
128         }
129
130         public Vector3 GetZAxis()
131         {
132             Vector3 ret = new Vector3(Interop.Matrix.GetZAxis(SwigCPtr), true);
133             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134             return ret;
135         }
136
137         public void SetXAxis(Vector3 axis)
138         {
139             Interop.Matrix.SetXAxis(SwigCPtr, Vector3.getCPtr(axis));
140             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141         }
142
143         public void SetYAxis(Vector3 axis)
144         {
145             Interop.Matrix.SetYAxis(SwigCPtr, Vector3.getCPtr(axis));
146             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147         }
148
149         public void SetZAxis(Vector3 axis)
150         {
151             Interop.Matrix.SetZAxis(SwigCPtr, Vector3.getCPtr(axis));
152             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153         }
154
155         public Vector4 GetTranslation()
156         {
157             Vector4 ret = new Vector4(Interop.Matrix.GetTranslation(SwigCPtr), false);
158             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
159             return ret;
160         }
161
162         public Vector3 GetTranslation3()
163         {
164             Vector3 ret = new Vector3(Interop.Matrix.GetTranslation3(SwigCPtr), false);
165             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166             return ret;
167         }
168
169         public void SetTranslation(Vector4 translation)
170         {
171             Interop.Matrix.SetTranslationVector4(SwigCPtr, Vector4.getCPtr(translation));
172             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173         }
174
175         public void SetTranslation(Vector3 translation)
176         {
177             Interop.Matrix.SetTranslationVector3(SwigCPtr, Vector3.getCPtr(translation));
178             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179         }
180
181         public void OrthoNormalize()
182         {
183             Interop.Matrix.OrthoNormalize(SwigCPtr);
184             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185         }
186
187         public SWIGTYPE_p_float AsFloat()
188         {
189             global::System.IntPtr cPtr = Interop.Matrix.AsFloat(SwigCPtr);
190             SWIGTYPE_p_float ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_float(cPtr);
191             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192             return ret;
193         }
194
195         public static void Multiply(Matrix result, Matrix lhs, Matrix rhs)
196         {
197             Interop.Matrix.Multiply(Matrix.getCPtr(result), Matrix.getCPtr(lhs), Matrix.getCPtr(rhs));
198             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199         }
200
201         public static void Multiply(Matrix result, Matrix lhs, Rotation rhs)
202         {
203             Interop.Matrix.MultiplyQuaternion(Matrix.getCPtr(result), Matrix.getCPtr(lhs), Rotation.getCPtr(rhs));
204             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205         }
206
207         public Vector4 Multiply(Vector4 rhs)
208         {
209             Vector4 ret = new Vector4(Interop.Matrix.Multiply(SwigCPtr, Vector4.getCPtr(rhs)), true);
210             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211             return ret;
212         }
213
214         public bool EqualTo(Matrix rhs)
215         {
216             bool ret = Interop.Matrix.EqualTo(SwigCPtr, Matrix.getCPtr(rhs));
217             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218             return ret;
219         }
220
221         public bool NotEqualTo(Matrix rhs)
222         {
223             bool ret = Interop.Matrix.NotEqualTo(SwigCPtr, Matrix.getCPtr(rhs));
224             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225             return ret;
226         }
227
228         public void SetTransformComponents(Vector3 scale, Rotation rotation, Vector3 translation)
229         {
230             Interop.Matrix.SetTransformComponents(SwigCPtr, Vector3.getCPtr(scale), Rotation.getCPtr(rotation), Vector3.getCPtr(translation));
231             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232         }
233
234         public void SetInverseTransformComponents(Vector3 scale, Rotation rotation, Vector3 translation)
235         {
236             Interop.Matrix.SetInverseTransformComponents(SwigCPtr, Vector3.getCPtr(scale), Rotation.getCPtr(rotation), Vector3.getCPtr(translation));
237             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238         }
239
240         public void SetInverseTransformComponents(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis, Vector3 translation)
241         {
242             Interop.Matrix.SetInverseTransformComponents(SwigCPtr, Vector3.getCPtr(xAxis), Vector3.getCPtr(yAxis), Vector3.getCPtr(zAxis), Vector3.getCPtr(translation));
243             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244         }
245
246         public void GetTransformComponents(Vector3 position, Rotation rotation, Vector3 scale)
247         {
248             Interop.Matrix.GetTransformComponents(SwigCPtr, Vector3.getCPtr(position), Rotation.getCPtr(rotation), Vector3.getCPtr(scale));
249             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250         }
251     }
252 }