Revert "[NUI] Refactoring Theme and StyleManager (#1981)" (#2013)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Rotation.cs
1 /*
2  * Copyright(c) 2019 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 using System.ComponentModel;
18 using Tizen.NUI.Binding;
19
20 namespace Tizen.NUI
21 {
22     /// <summary>
23     /// The Rotation class.
24     /// </summary>
25     /// <since_tizen> 3 </since_tizen>
26     [Binding.TypeConverter(typeof(RotationTypeConverter))]
27     public class Rotation : Disposable
28     {
29
30         /// <summary>
31         /// The default constructor.
32         /// </summary>
33         /// <since_tizen> 3 </since_tizen>
34         public Rotation() : this(Interop.Rotation.new_Rotation__SWIG_0(), true)
35         {
36             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
37         }
38
39         /// <summary>
40         /// The constructor from an axis and angle.
41         /// </summary>
42         /// <param name="angle">The angle around the axis.</param>
43         /// <param name="axis">The vector of the axis.</param>
44         /// <since_tizen> 3 </since_tizen>
45         public Rotation(Radian angle, Vector3 axis) : this(Interop.Rotation.new_Rotation__SWIG_1(Radian.getCPtr(angle), Vector3.getCPtr(axis)), true)
46         {
47             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
48         }
49
50         /// <summary>
51         /// (0.0f,0.0f,0.0f,1.0f).
52         /// </summary>
53         /// <since_tizen> 3 </since_tizen>
54         public static Rotation IDENTITY
55         {
56             get
57             {
58                 global::System.IntPtr cPtr = Interop.Rotation.Rotation_IDENTITY_get();
59                 Rotation ret = (cPtr == global::System.IntPtr.Zero) ? null : new Rotation(cPtr, false);
60                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
61                 return ret;
62             }
63         }
64
65         /// <summary>
66         /// The addition operator.
67         /// </summary>
68         /// <param name="arg1">The first rotation.</param>
69         /// <param name="arg2">The second rotation.</param>
70         /// <returns>The rotation containing the result of the addition.</returns>
71         /// <since_tizen> 3 </since_tizen>
72         public static Rotation operator +(Rotation arg1, Rotation arg2)
73         {
74             return arg1.Add(arg2);
75         }
76
77         /// <summary>
78         /// The subtraction operator.
79         /// </summary>
80         /// <param name="arg1">The first rotation.</param>
81         /// <param name="arg2">The second rotation.</param>
82         /// <returns>The rotation containing the result of the subtraction.</returns>
83         /// <since_tizen> 3 </since_tizen>
84         public static Rotation operator -(Rotation arg1, Rotation arg2)
85         {
86             return arg1.Subtract(arg2);
87         }
88
89         /// <summary>
90         /// The unary negation operator.
91         /// </summary>
92         /// <param name="arg1">The first rotation.</param>
93         /// <returns>The rotation containing the negated result.</returns>
94         /// <since_tizen> 3 </since_tizen>
95         public static Rotation operator -(Rotation arg1)
96         {
97             return arg1.Subtract();
98         }
99
100         /// <summary>
101         /// The multiplication operator.
102         /// </summary>
103         /// <param name="arg1">The first rotation.</param>
104         /// <param name="arg2">The second rotation.</param>
105         /// <returns>The rotation containing the result of the multiplication.</returns>
106         /// <since_tizen> 3 </since_tizen>
107         public static Rotation operator *(Rotation arg1, Rotation arg2)
108         {
109             return arg1.Multiply(arg2);
110         }
111
112         /// <summary>
113         /// The multiplication operator.
114         /// </summary>
115         /// <param name="arg1">Rotation.</param>
116         /// <param name="arg2">The vector to multiply.</param>
117         /// <returns>The rotation containing the result of the multiplication.</returns>
118         /// <since_tizen> 3 </since_tizen>
119         public static Vector3 operator *(Rotation arg1, Vector3 arg2)
120         {
121             return arg1.Multiply(arg2);
122         }
123
124         /// <summary>
125         /// The scale operator.
126         /// </summary>
127         /// <param name="arg1">Rotation.</param>
128         /// <param name="arg2">A value to scale by.</param>
129         /// <returns>The rotation containing the result of scaling.</returns>
130         /// <since_tizen> 3 </since_tizen>
131         public static Rotation operator *(Rotation arg1, float arg2)
132         {
133             return arg1.Multiply(arg2);
134         }
135
136         /// <summary>
137         /// The division operator.
138         /// </summary>
139         /// <param name="arg1">The first rotation.</param>
140         /// <param name="arg2">The second rotation.</param>
141         /// <returns>The rotation containing the result of scaling.</returns>
142         /// <since_tizen> 3 </since_tizen>
143         public static Rotation operator /(Rotation arg1, Rotation arg2)
144         {
145             return arg1.Divide(arg2);
146         }
147
148         /// <summary>
149         /// The scale operator.
150         /// </summary>
151         /// <param name="arg1">Rotation.</param>
152         /// <param name="arg2">A value to scale by.</param>
153         /// <returns>The rotation containing the result of scaling.</returns>
154         /// <since_tizen> 3 </since_tizen>
155         public static Rotation operator /(Rotation arg1, float arg2)
156         {
157             return arg1.Divide(arg2);
158         }
159
160         /// <summary>
161         /// Returns the dot product of two rotations.
162         /// </summary>
163         /// <param name="q1">The first rotation.</param>
164         /// <param name="q2">The second rotation.</param>
165         /// <returns>The dot product of the two rotations.</returns>
166         /// <since_tizen> 3 </since_tizen>
167         public static float Dot(Rotation q1, Rotation q2)
168         {
169             float ret = Interop.Rotation.Rotation_Dot(Rotation.getCPtr(q1), Rotation.getCPtr(q2));
170             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171             return ret;
172         }
173
174         /// <summary>
175         /// The linear iterpolation (using a straight line between the two rotations).
176         /// </summary>
177         /// <param name="q1">The start rotation.</param>
178         /// <param name="q2">The end rotation.</param>
179         /// <param name="t">A progress value between 0 and 1.</param>
180         /// <returns>The interpolated rotation.</returns>
181         /// <since_tizen> 3 </since_tizen>
182         public static Rotation Lerp(Rotation q1, Rotation q2, float t)
183         {
184             Rotation ret = new Rotation(Interop.Rotation.Rotation_Lerp(Rotation.getCPtr(q1), Rotation.getCPtr(q2), t), true);
185             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186             return ret;
187         }
188
189         /// <summary>
190         /// The spherical linear interpolation (using the shortest arc of a great circle between the two rotations).
191         /// </summary>
192         /// <param name="q1">The start rotation.</param>
193         /// <param name="q2">The end rotation.</param>
194         /// <param name="progress">A progress value between 0 and 1.</param>
195         /// <returns>The interpolated rotation.</returns>
196         /// <since_tizen> 3 </since_tizen>
197         public static Rotation Slerp(Rotation q1, Rotation q2, float progress)
198         {
199             Rotation ret = new Rotation(Interop.Rotation.Rotation_Slerp(Rotation.getCPtr(q1), Rotation.getCPtr(q2), progress), true);
200             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201             return ret;
202         }
203
204         /// <summary>
205         /// This version of slerp, used by squad, does not check for theta > 90.
206         /// </summary>
207         /// <param name="q1">The start rotation.</param>
208         /// <param name="q2">The end rotation.</param>
209         /// <param name="t">A progress value between 0 and 1.</param>
210         /// <returns>The interpolated rotation.</returns>
211         /// <since_tizen> 3 </since_tizen>
212         public static Rotation SlerpNoInvert(Rotation q1, Rotation q2, float t)
213         {
214             Rotation ret = new Rotation(Interop.Rotation.Rotation_SlerpNoInvert(Rotation.getCPtr(q1), Rotation.getCPtr(q2), t), true);
215             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
216             return ret;
217         }
218
219         /// <summary>
220         /// The spherical cubic interpolation.
221         /// </summary>
222         /// <param name="start">The start rotation.</param>
223         /// <param name="end">The end rotation.</param>
224         /// <param name="ctrl1">The control rotation for q1.</param>
225         /// <param name="ctrl2">The control rotation for q2.</param>
226         /// <param name="t">A progress value between 0 and 1.</param>
227         /// <returns>The interpolated rotation.</returns>
228         /// <since_tizen> 3 </since_tizen>
229         public static Rotation Squad(Rotation start, Rotation end, Rotation ctrl1, Rotation ctrl2, float t)
230         {
231             Rotation ret = new Rotation(Interop.Rotation.Rotation_Squad(Rotation.getCPtr(start), Rotation.getCPtr(end), Rotation.getCPtr(ctrl1), Rotation.getCPtr(ctrl2), t), true);
232             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233             return ret;
234         }
235
236         /// <summary>
237         /// Returns the shortest angle between two rotations in radians.
238         /// </summary>
239         /// <param name="q1">The first rotation.</param>
240         /// <param name="q2">The second rotation.</param>
241         /// <returns>The angle between the two rotation.</returns>
242         /// <since_tizen> 3 </since_tizen>
243         public static float AngleBetween(Rotation q1, Rotation q2)
244         {
245             float ret = Interop.Rotation.Rotation_AngleBetween(Rotation.getCPtr(q1), Rotation.getCPtr(q2));
246             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247             return ret;
248         }
249
250         /// <summary>
251         /// Helper to check if this is an identity quaternion.
252         /// </summary>
253         /// <returns>True if this is identity quaternion.</returns>
254         /// <since_tizen> 3 </since_tizen>
255         public bool IsIdentity()
256         {
257             bool ret = Interop.Rotation.Rotation_IsIdentity(swigCPtr);
258             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
259             return ret;
260         }
261
262         /// <summary>
263         /// Converts the quaternion to an axis or angle pair.
264         /// </summary>
265         /// <param name="axis">The result of an an axis.</param>
266         /// <param name="angle">The result of angle in radians.</param>
267         /// <returns>True if converted correctly.</returns>
268         /// <since_tizen> 3 </since_tizen>
269         public bool GetAxisAngle(Vector3 axis, Radian angle)
270         {
271             bool ret = Interop.Rotation.Rotation_GetAxisAngle(swigCPtr, Vector3.getCPtr(axis), Radian.getCPtr(angle));
272             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273             return ret;
274         }
275
276         /// <summary>
277         /// Returns the length of the rotation.
278         /// </summary>
279         /// <returns>The length of the rotation.</returns>
280         /// <since_tizen> 3 </since_tizen>
281         public float Length()
282         {
283             float ret = Interop.Rotation.Rotation_Length(swigCPtr);
284             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285             return ret;
286         }
287
288         /// <summary>
289         /// Returns the squared length of the rotation.
290         /// </summary>
291         /// <returns>The squared length of the rotation.</returns>
292         /// <since_tizen> 3 </since_tizen>
293         public float LengthSquared()
294         {
295             float ret = Interop.Rotation.Rotation_LengthSquared(swigCPtr);
296             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297             return ret;
298         }
299
300         /// <summary>
301         /// Normalizes this to unit length.
302         /// </summary>
303         /// <since_tizen> 3 </since_tizen>
304         public void Normalize()
305         {
306             Interop.Rotation.Rotation_Normalize(swigCPtr);
307             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
308         }
309
310         /// <summary>
311         /// Normalized.
312         /// </summary>
313         /// <returns>A normalized version of this rotation.</returns>
314         /// <since_tizen> 3 </since_tizen>
315         public Rotation Normalized()
316         {
317             Rotation ret = new Rotation(Interop.Rotation.Rotation_Normalized(swigCPtr), true);
318             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319             return ret;
320         }
321
322         /// <summary>
323         /// Conjugates this rotation.
324         /// </summary>
325         /// <since_tizen> 3 </since_tizen>
326         public void Conjugate()
327         {
328             Interop.Rotation.Rotation_Conjugate(swigCPtr);
329             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330         }
331
332         /// <summary>
333         /// Inverts this rotation.
334         /// </summary>
335         /// <since_tizen> 3 </since_tizen>
336         public void Invert()
337         {
338             Interop.Rotation.Rotation_Invert(swigCPtr);
339             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
340         }
341
342         /// <summary>
343         /// Performs the logarithm of a rotation.
344         /// </summary>
345         /// <returns>The rotation representing the logarithm.</returns>
346         /// <since_tizen> 3 </since_tizen>
347         public Rotation Log()
348         {
349             Rotation ret = new Rotation(Interop.Rotation.Rotation_Log(swigCPtr), true);
350             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
351             return ret;
352         }
353
354         /// <summary>
355         /// Performs an exponent.
356         /// </summary>
357         /// <returns>The rotation representing the exponent.</returns>
358         /// <since_tizen> 3 </since_tizen>
359         public Rotation Exp()
360         {
361             Rotation ret = new Rotation(Interop.Rotation.Rotation_Exp(swigCPtr), true);
362             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
363             return ret;
364         }
365
366         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Rotation obj)
367         {
368             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
369         }
370
371         internal Rotation(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
372         {
373         }
374
375         /// This will not be public opened.
376         [EditorBrowsable(EditorBrowsableState.Never)]
377         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
378         {
379             Interop.Rotation.delete_Rotation(swigCPtr);
380         }
381
382         private Rotation Add(Rotation other)
383         {
384             Rotation ret = new Rotation(Interop.Rotation.Rotation_Add(swigCPtr, Rotation.getCPtr(other)), true);
385             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
386             return ret;
387         }
388
389         private Rotation Subtract(Rotation other)
390         {
391             Rotation ret = new Rotation(Interop.Rotation.Rotation_Subtract__SWIG_0(swigCPtr, Rotation.getCPtr(other)), true);
392             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
393             return ret;
394         }
395
396         private Rotation Multiply(Rotation other)
397         {
398             Rotation ret = new Rotation(Interop.Rotation.Rotation_Multiply__SWIG_0(swigCPtr, Rotation.getCPtr(other)), true);
399             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
400             return ret;
401         }
402
403         private Vector3 Multiply(Vector3 other)
404         {
405             Vector3 ret = new Vector3(Interop.Rotation.Rotation_Multiply__SWIG_1(swigCPtr, Vector3.getCPtr(other)), true);
406             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
407             return ret;
408         }
409
410         private Rotation Divide(Rotation other)
411         {
412             Rotation ret = new Rotation(Interop.Rotation.Rotation_Divide__SWIG_0(swigCPtr, Rotation.getCPtr(other)), true);
413             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
414             return ret;
415         }
416
417         private Rotation Multiply(float scale)
418         {
419             Rotation ret = new Rotation(Interop.Rotation.Rotation_Multiply__SWIG_2(swigCPtr, scale), true);
420             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
421             return ret;
422         }
423
424         private Rotation Divide(float scale)
425         {
426             Rotation ret = new Rotation(Interop.Rotation.Rotation_Divide__SWIG_1(swigCPtr, scale), true);
427             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
428             return ret;
429         }
430
431         private Rotation Subtract()
432         {
433             Rotation ret = new Rotation(Interop.Rotation.Rotation_Subtract__SWIG_1(swigCPtr), true);
434             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
435             return ret;
436         }
437
438         private Rotation AddAssign(Rotation other)
439         {
440             Rotation ret = new Rotation(Interop.Rotation.Rotation_AddAssign(swigCPtr, Rotation.getCPtr(other)), false);
441             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
442             return ret;
443         }
444
445         private Rotation SubtractAssign(Rotation other)
446         {
447             Rotation ret = new Rotation(Interop.Rotation.Rotation_SubtractAssign(swigCPtr, Rotation.getCPtr(other)), false);
448             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
449             return ret;
450         }
451
452         private Rotation MultiplyAssign(Rotation other)
453         {
454             Rotation ret = new Rotation(Interop.Rotation.Rotation_MultiplyAssign__SWIG_0(swigCPtr, Rotation.getCPtr(other)), false);
455             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
456             return ret;
457         }
458
459         private Rotation MultiplyAssign(float scale)
460         {
461             Rotation ret = new Rotation(Interop.Rotation.Rotation_MultiplyAssign__SWIG_1(swigCPtr, scale), false);
462             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
463             return ret;
464         }
465
466         private Rotation DivideAssign(float scale)
467         {
468             Rotation ret = new Rotation(Interop.Rotation.Rotation_DivideAssign(swigCPtr, scale), false);
469             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
470             return ret;
471         }
472
473         private bool EqualTo(Rotation rhs)
474         {
475             bool ret = Interop.Rotation.Rotation_EqualTo(swigCPtr, Rotation.getCPtr(rhs));
476             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
477             return ret;
478         }
479
480         private bool NotEqualTo(Rotation rhs)
481         {
482             bool ret = Interop.Rotation.Rotation_NotEqualTo(swigCPtr, Rotation.getCPtr(rhs));
483             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
484             return ret;
485         }
486     }
487 }