2 * Copyright(c) 2017 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.
18 using Tizen.NUI.Binding;
23 /// The Rotation class.
25 /// <since_tizen> 3 </since_tizen>
26 [TypeConverter(typeof(RotationTypeConverter))]
27 public class Rotation : Disposable
32 /// <since_tizen> 3 </since_tizen>
33 protected bool swigCMemOwn;
35 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
38 /// The default constructor.
40 /// <since_tizen> 3 </since_tizen>
41 public Rotation() : this(Interop.Rotation.new_Rotation__SWIG_0(), true)
43 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
47 /// The constructor from an axis and angle.
49 /// <param name="angle">The angle around the axis.</param>
50 /// <param name="axis">The vector of the axis.</param>
51 /// <since_tizen> 3 </since_tizen>
52 public Rotation(Radian angle, Vector3 axis) : this(Interop.Rotation.new_Rotation__SWIG_1(Radian.getCPtr(angle), Vector3.getCPtr(axis)), true)
54 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
58 /// (0.0f,0.0f,0.0f,1.0f).
60 /// <since_tizen> 3 </since_tizen>
61 public static Rotation IDENTITY
65 global::System.IntPtr cPtr = Interop.Rotation.Rotation_IDENTITY_get();
66 Rotation ret = (cPtr == global::System.IntPtr.Zero) ? null : new Rotation(cPtr, false);
67 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
73 /// The addition operator.
75 /// <param name="arg1">The first rotation.</param>
76 /// <param name="arg2">The second rotation.</param>
77 /// <returns>The rotation containing the result of the addition.</returns>
78 /// <since_tizen> 3 </since_tizen>
79 public static Rotation operator +(Rotation arg1, Rotation arg2)
81 return arg1.Add(arg2);
85 /// The subtraction operator.
87 /// <param name="arg1">The first rotation.</param>
88 /// <param name="arg2">The second rotation.</param>
89 /// <returns>The rotation containing the result of the subtraction.</returns>
90 /// <since_tizen> 3 </since_tizen>
91 public static Rotation operator -(Rotation arg1, Rotation arg2)
93 return arg1.Subtract(arg2);
97 /// The unary negation operator.
99 /// <param name="arg1">The first rotation.</param>
100 /// <returns>The rotation containing the negated result.</returns>
101 /// <since_tizen> 3 </since_tizen>
102 public static Rotation operator -(Rotation arg1)
104 return arg1.Subtract();
108 /// The multiplication operator.
110 /// <param name="arg1">The first rotation.</param>
111 /// <param name="arg2">The second rotation.</param>
112 /// <returns>The rotation containing the result of the multiplication.</returns>
113 /// <since_tizen> 3 </since_tizen>
114 public static Rotation operator *(Rotation arg1, Rotation arg2)
116 return arg1.Multiply(arg2);
120 /// The multiplication operator.
122 /// <param name="arg1">Rotation.</param>
123 /// <param name="arg2">The vector to multiply.</param>
124 /// <returns>The rotation containing the result of the multiplication.</returns>
125 /// <since_tizen> 3 </since_tizen>
126 public static Vector3 operator *(Rotation arg1, Vector3 arg2)
128 return arg1.Multiply(arg2);
132 /// The scale operator.
134 /// <param name="arg1">Rotation.</param>
135 /// <param name="arg2">A value to scale by.</param>
136 /// <returns>The rotation containing the result of scaling.</returns>
137 /// <since_tizen> 3 </since_tizen>
138 public static Rotation operator *(Rotation arg1, float arg2)
140 return arg1.Multiply(arg2);
144 /// The division operator.
146 /// <param name="arg1">The first rotation.</param>
147 /// <param name="arg2">The second rotation.</param>
148 /// <returns>The rotation containing the result of scaling.</returns>
149 /// <since_tizen> 3 </since_tizen>
150 public static Rotation operator /(Rotation arg1, Rotation arg2)
152 return arg1.Divide(arg2);
156 /// The scale operator.
158 /// <param name="arg1">Rotation.</param>
159 /// <param name="arg2">A value to scale by.</param>
160 /// <returns>The rotation containing the result of scaling.</returns>
161 /// <since_tizen> 3 </since_tizen>
162 public static Rotation operator /(Rotation arg1, float arg2)
164 return arg1.Divide(arg2);
168 /// Returns the dot product of two rotations.
170 /// <param name="q1">The first rotation.</param>
171 /// <param name="q2">The second rotation.</param>
172 /// <returns>The dot product of the two rotations.</returns>
173 /// <since_tizen> 3 </since_tizen>
174 public static float Dot(Rotation q1, Rotation q2)
176 float ret = Interop.Rotation.Rotation_Dot(Rotation.getCPtr(q1), Rotation.getCPtr(q2));
177 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182 /// The linear iterpolation (using a straight line between the two rotations).
184 /// <param name="q1">The start rotation.</param>
185 /// <param name="q2">The end rotation.</param>
186 /// <param name="t">A progress value between 0 and 1.</param>
187 /// <returns>The interpolated rotation.</returns>
188 /// <since_tizen> 3 </since_tizen>
189 public static Rotation Lerp(Rotation q1, Rotation q2, float t)
191 Rotation ret = new Rotation(Interop.Rotation.Rotation_Lerp(Rotation.getCPtr(q1), Rotation.getCPtr(q2), t), true);
192 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197 /// The spherical linear interpolation (using the shortest arc of a great circle between the two rotations).
199 /// <param name="q1">The start rotation.</param>
200 /// <param name="q2">The end rotation.</param>
201 /// <param name="progress">A progress value between 0 and 1.</param>
202 /// <returns>The interpolated rotation.</returns>
203 /// <since_tizen> 3 </since_tizen>
204 public static Rotation Slerp(Rotation q1, Rotation q2, float progress)
206 Rotation ret = new Rotation(Interop.Rotation.Rotation_Slerp(Rotation.getCPtr(q1), Rotation.getCPtr(q2), progress), true);
207 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212 /// This version of slerp, used by squad, does not check for theta > 90.
214 /// <param name="q1">The start rotation.</param>
215 /// <param name="q2">The end rotation.</param>
216 /// <param name="t">A progress value between 0 and 1.</param>
217 /// <returns>The interpolated rotation.</returns>
218 /// <since_tizen> 3 </since_tizen>
219 public static Rotation SlerpNoInvert(Rotation q1, Rotation q2, float t)
221 Rotation ret = new Rotation(Interop.Rotation.Rotation_SlerpNoInvert(Rotation.getCPtr(q1), Rotation.getCPtr(q2), t), true);
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227 /// The spherical cubic interpolation.
229 /// <param name="start">The start rotation.</param>
230 /// <param name="end">The end rotation.</param>
231 /// <param name="ctrl1">The control rotation for q1.</param>
232 /// <param name="ctrl2">The control rotation for q2.</param>
233 /// <param name="t">A progress value between 0 and 1.</param>
234 /// <returns>The interpolated rotation.</returns>
235 /// <since_tizen> 3 </since_tizen>
236 public static Rotation Squad(Rotation start, Rotation end, Rotation ctrl1, Rotation ctrl2, float t)
238 Rotation ret = new Rotation(Interop.Rotation.Rotation_Squad(Rotation.getCPtr(start), Rotation.getCPtr(end), Rotation.getCPtr(ctrl1), Rotation.getCPtr(ctrl2), t), true);
239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244 /// Returns the shortest angle between two rotations in radians.
246 /// <param name="q1">The first rotation.</param>
247 /// <param name="q2">The second rotation.</param>
248 /// <returns>The angle between the two rotation.</returns>
249 /// <since_tizen> 3 </since_tizen>
250 public static float AngleBetween(Rotation q1, Rotation q2)
252 float ret = Interop.Rotation.Rotation_AngleBetween(Rotation.getCPtr(q1), Rotation.getCPtr(q2));
253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
258 /// Helper to check if this is an identity quaternion.
260 /// <returns>True if this is identity quaternion.</returns>
261 /// <since_tizen> 3 </since_tizen>
262 public bool IsIdentity()
264 bool ret = Interop.Rotation.Rotation_IsIdentity(swigCPtr);
265 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
270 /// Converts the quaternion to an axis or angle pair.
272 /// <param name="axis">The result of an an axis.</param>
273 /// <param name="angle">The result of angle in radians.</param>
274 /// <returns>True if converted correctly.</returns>
275 /// <since_tizen> 3 </since_tizen>
276 public bool GetAxisAngle(Vector3 axis, Radian angle)
278 bool ret = Interop.Rotation.Rotation_GetAxisAngle(swigCPtr, Vector3.getCPtr(axis), Radian.getCPtr(angle));
279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284 /// Returns the length of the rotation.
286 /// <returns>The length of the rotation.</returns>
287 /// <since_tizen> 3 </since_tizen>
288 public float Length()
290 float ret = Interop.Rotation.Rotation_Length(swigCPtr);
291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 /// Returns the squared length of the rotation.
298 /// <returns>The squared length of the rotation.</returns>
299 /// <since_tizen> 3 </since_tizen>
300 public float LengthSquared()
302 float ret = Interop.Rotation.Rotation_LengthSquared(swigCPtr);
303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
308 /// Normalizes this to unit length.
310 /// <since_tizen> 3 </since_tizen>
311 public void Normalize()
313 Interop.Rotation.Rotation_Normalize(swigCPtr);
314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
320 /// <returns>A normalized version of this rotation.</returns>
321 /// <since_tizen> 3 </since_tizen>
322 public Rotation Normalized()
324 Rotation ret = new Rotation(Interop.Rotation.Rotation_Normalized(swigCPtr), true);
325 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330 /// Conjugates this rotation.
332 /// <since_tizen> 3 </since_tizen>
333 public void Conjugate()
335 Interop.Rotation.Rotation_Conjugate(swigCPtr);
336 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
340 /// Inverts this rotation.
342 /// <since_tizen> 3 </since_tizen>
345 Interop.Rotation.Rotation_Invert(swigCPtr);
346 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
350 /// Performs the logarithm of a rotation.
352 /// <returns>The rotation representing the logarithm.</returns>
353 /// <since_tizen> 3 </since_tizen>
354 public Rotation Log()
356 Rotation ret = new Rotation(Interop.Rotation.Rotation_Log(swigCPtr), true);
357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362 /// Performs an exponent.
364 /// <returns>The rotation representing the exponent.</returns>
365 /// <since_tizen> 3 </since_tizen>
366 public Rotation Exp()
368 Rotation ret = new Rotation(Interop.Rotation.Rotation_Exp(swigCPtr), true);
369 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
373 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Rotation obj)
375 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
378 internal Rotation(global::System.IntPtr cPtr, bool cMemoryOwn)
380 swigCMemOwn = cMemoryOwn;
381 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
387 /// <since_tizen> 3 </since_tizen>
388 protected override void Dispose(DisposeTypes type)
395 //Release your own unmanaged resources here.
396 //You should not access any managed member here except static instance.
397 //because the execution order of Finalizes is non-deterministic.
399 if (swigCPtr.Handle != global::System.IntPtr.Zero)
404 Interop.Rotation.delete_Rotation(swigCPtr);
406 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
411 private Rotation Add(Rotation other)
413 Rotation ret = new Rotation(Interop.Rotation.Rotation_Add(swigCPtr, Rotation.getCPtr(other)), true);
414 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418 private Rotation Subtract(Rotation other)
420 Rotation ret = new Rotation(Interop.Rotation.Rotation_Subtract__SWIG_0(swigCPtr, Rotation.getCPtr(other)), true);
421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
425 private Rotation Multiply(Rotation other)
427 Rotation ret = new Rotation(Interop.Rotation.Rotation_Multiply__SWIG_0(swigCPtr, Rotation.getCPtr(other)), true);
428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
432 private Vector3 Multiply(Vector3 other)
434 Vector3 ret = new Vector3(Interop.Rotation.Rotation_Multiply__SWIG_1(swigCPtr, Vector3.getCPtr(other)), true);
435 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
439 private Rotation Divide(Rotation other)
441 Rotation ret = new Rotation(Interop.Rotation.Rotation_Divide__SWIG_0(swigCPtr, Rotation.getCPtr(other)), true);
442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
446 private Rotation Multiply(float scale)
448 Rotation ret = new Rotation(Interop.Rotation.Rotation_Multiply__SWIG_2(swigCPtr, scale), true);
449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
453 private Rotation Divide(float scale)
455 Rotation ret = new Rotation(Interop.Rotation.Rotation_Divide__SWIG_1(swigCPtr, scale), true);
456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
460 private Rotation Subtract()
462 Rotation ret = new Rotation(Interop.Rotation.Rotation_Subtract__SWIG_1(swigCPtr), true);
463 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
467 private Rotation AddAssign(Rotation other)
469 Rotation ret = new Rotation(Interop.Rotation.Rotation_AddAssign(swigCPtr, Rotation.getCPtr(other)), false);
470 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
474 private Rotation SubtractAssign(Rotation other)
476 Rotation ret = new Rotation(Interop.Rotation.Rotation_SubtractAssign(swigCPtr, Rotation.getCPtr(other)), false);
477 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
481 private Rotation MultiplyAssign(Rotation other)
483 Rotation ret = new Rotation(Interop.Rotation.Rotation_MultiplyAssign__SWIG_0(swigCPtr, Rotation.getCPtr(other)), false);
484 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
488 private Rotation MultiplyAssign(float scale)
490 Rotation ret = new Rotation(Interop.Rotation.Rotation_MultiplyAssign__SWIG_1(swigCPtr, scale), false);
491 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
495 private Rotation DivideAssign(float scale)
497 Rotation ret = new Rotation(Interop.Rotation.Rotation_DivideAssign(swigCPtr, scale), false);
498 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
502 private bool EqualTo(Rotation rhs)
504 bool ret = Interop.Rotation.Rotation_EqualTo(swigCPtr, Rotation.getCPtr(rhs));
505 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
509 private bool NotEqualTo(Rotation rhs)
511 bool ret = Interop.Rotation.Rotation_NotEqualTo(swigCPtr, Rotation.getCPtr(rhs));
512 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();