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