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