2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 using System.ComponentModel;
18 using Tizen.NUI.Binding;
23 /// The Rotation class.
25 /// <since_tizen> 3 </since_tizen>
26 [Binding.TypeConverter(typeof(RotationTypeConverter))]
27 public class Rotation : Disposable
31 /// The default constructor.
33 /// <since_tizen> 3 </since_tizen>
34 public Rotation() : this(Interop.Rotation.new_Rotation__SWIG_0(), true)
36 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
40 /// The constructor from an axis and angle.
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)
47 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
51 /// (0.0f,0.0f,0.0f,1.0f).
53 /// <since_tizen> 3 </since_tizen>
54 public static Rotation IDENTITY
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();
66 /// The addition operator.
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)
74 return arg1?.Add(arg2);
78 /// The subtraction operator.
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)
86 return arg1?.Subtract(arg2);
90 /// The unary negation operator.
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)
97 return arg1?.Subtract();
101 /// The multiplication operator.
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)
109 return arg1?.Multiply(arg2);
113 /// The multiplication operator.
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)
121 return arg1?.Multiply(arg2);
125 /// The scale operator.
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)
133 return arg1?.Multiply(arg2);
137 /// The division operator.
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)
145 return arg1?.Divide(arg2);
149 /// The scale operator.
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)
157 return arg1?.Divide(arg2);
161 /// Returns the dot product of two rotations.
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)
169 float ret = Interop.Rotation.Rotation_Dot(Rotation.getCPtr(q1), Rotation.getCPtr(q2));
170 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175 /// The linear iterpolation (using a straight line between the two rotations).
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)
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();
190 /// The spherical linear interpolation (using the shortest arc of a great circle between the two rotations).
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)
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();
205 /// This version of slerp, used by squad, does not check for theta > 90.
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)
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();
220 /// The spherical cubic interpolation.
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)
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();
237 /// Returns the shortest angle between two rotations in radians.
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)
245 float ret = Interop.Rotation.Rotation_AngleBetween(Rotation.getCPtr(q1), Rotation.getCPtr(q2));
246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 /// Helper to check if this is an identity quaternion.
253 /// <returns>True if this is identity quaternion.</returns>
254 /// <since_tizen> 3 </since_tizen>
255 public bool IsIdentity()
257 bool ret = Interop.Rotation.Rotation_IsIdentity(swigCPtr);
258 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263 /// Converts the quaternion to an axis or angle pair.
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)
271 bool ret = Interop.Rotation.Rotation_GetAxisAngle(swigCPtr, Vector3.getCPtr(axis), Radian.getCPtr(angle));
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277 /// Returns the length of the rotation.
279 /// <returns>The length of the rotation.</returns>
280 /// <since_tizen> 3 </since_tizen>
281 public float Length()
283 float ret = Interop.Rotation.Rotation_Length(swigCPtr);
284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289 /// Returns the squared length of the rotation.
291 /// <returns>The squared length of the rotation.</returns>
292 /// <since_tizen> 3 </since_tizen>
293 public float LengthSquared()
295 float ret = Interop.Rotation.Rotation_LengthSquared(swigCPtr);
296 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
301 /// Normalizes this to unit length.
303 /// <since_tizen> 3 </since_tizen>
304 public void Normalize()
306 Interop.Rotation.Rotation_Normalize(swigCPtr);
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313 /// <returns>A normalized version of this rotation.</returns>
314 /// <since_tizen> 3 </since_tizen>
315 public Rotation Normalized()
317 Rotation ret = new Rotation(Interop.Rotation.Rotation_Normalized(swigCPtr), true);
318 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323 /// Conjugates this rotation.
325 /// <since_tizen> 3 </since_tizen>
326 public void Conjugate()
328 Interop.Rotation.Rotation_Conjugate(swigCPtr);
329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
333 /// Inverts this rotation.
335 /// <since_tizen> 3 </since_tizen>
338 Interop.Rotation.Rotation_Invert(swigCPtr);
339 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
343 /// Performs the logarithm of a rotation.
345 /// <returns>The rotation representing the logarithm.</returns>
346 /// <since_tizen> 3 </since_tizen>
347 public Rotation Log()
349 Rotation ret = new Rotation(Interop.Rotation.Rotation_Log(swigCPtr), true);
350 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
355 /// Performs an exponent.
357 /// <returns>The rotation representing the exponent.</returns>
358 /// <since_tizen> 3 </since_tizen>
359 public Rotation Exp()
361 Rotation ret = new Rotation(Interop.Rotation.Rotation_Exp(swigCPtr), true);
362 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
366 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Rotation obj)
368 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
371 internal Rotation(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
375 /// This will not be public opened.
376 [EditorBrowsable(EditorBrowsableState.Never)]
377 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
379 Interop.Rotation.delete_Rotation(swigCPtr);
382 private Rotation Add(Rotation other)
384 Rotation ret = new Rotation(Interop.Rotation.Rotation_Add(swigCPtr, Rotation.getCPtr(other)), true);
385 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
389 private Rotation Subtract(Rotation other)
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();
396 private Rotation Multiply(Rotation other)
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();
403 private Vector3 Multiply(Vector3 other)
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();
410 private Rotation Divide(Rotation other)
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();
417 private Rotation Multiply(float scale)
419 Rotation ret = new Rotation(Interop.Rotation.Rotation_Multiply__SWIG_2(swigCPtr, scale), true);
420 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424 private Rotation Divide(float scale)
426 Rotation ret = new Rotation(Interop.Rotation.Rotation_Divide__SWIG_1(swigCPtr, scale), true);
427 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
431 private Rotation Subtract()
433 Rotation ret = new Rotation(Interop.Rotation.Rotation_Subtract__SWIG_1(swigCPtr), true);
434 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
438 private Rotation AddAssign(Rotation other)
440 Rotation ret = new Rotation(Interop.Rotation.Rotation_AddAssign(swigCPtr, Rotation.getCPtr(other)), false);
441 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
445 private Rotation SubtractAssign(Rotation other)
447 Rotation ret = new Rotation(Interop.Rotation.Rotation_SubtractAssign(swigCPtr, Rotation.getCPtr(other)), false);
448 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452 private Rotation MultiplyAssign(Rotation other)
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();
459 private Rotation MultiplyAssign(float scale)
461 Rotation ret = new Rotation(Interop.Rotation.Rotation_MultiplyAssign__SWIG_1(swigCPtr, scale), false);
462 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
466 private Rotation DivideAssign(float scale)
468 Rotation ret = new Rotation(Interop.Rotation.Rotation_DivideAssign(swigCPtr, scale), false);
469 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
473 private bool EqualTo(Rotation rhs)
475 bool ret = Interop.Rotation.Rotation_EqualTo(swigCPtr, Rotation.getCPtr(rhs));
476 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480 private bool NotEqualTo(Rotation rhs)
482 bool ret = Interop.Rotation.Rotation_NotEqualTo(swigCPtr, Rotation.getCPtr(rhs));
483 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();