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