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.
18 using System.ComponentModel;
19 using Tizen.NUI.Binding;
24 /// The Rotation class.
26 /// <since_tizen> 3 </since_tizen>
27 [Binding.TypeConverter(typeof(RotationTypeConverter))]
28 public class Rotation : Disposable
32 /// The default constructor.
34 /// <since_tizen> 3 </since_tizen>
35 public Rotation() : this(Interop.Rotation.NewRotation(), true)
37 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
41 /// The constructor from an axis and angle.
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)
48 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
52 /// (0.0f,0.0f,0.0f,1.0f).
54 /// <since_tizen> 3 </since_tizen>
55 public static Rotation IDENTITY
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());
67 /// The addition operator.
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)
75 return arg1?.Add(arg2);
79 /// The subtraction operator.
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)
87 return arg1?.Subtract(arg2);
91 /// The unary negation operator.
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)
98 return arg1?.Subtract();
102 /// The multiplication operator.
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)
110 return arg1?.Multiply(arg2);
114 /// The multiplication operator.
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)
122 return arg1?.Multiply(arg2);
126 /// The scale operator.
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)
134 return arg1?.Multiply(arg2);
138 /// The division operator.
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)
146 return arg1?.Divide(arg2);
150 /// The scale operator.
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)
158 return arg1?.Divide(arg2);
162 /// Returns the dot product of two rotations.
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)
170 float ret = Interop.Rotation.Dot(Rotation.getCPtr(q1), Rotation.getCPtr(q2));
171 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176 /// The linear iterpolation (using a straight line between the two rotations).
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)
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();
191 /// The spherical linear interpolation (using the shortest arc of a great circle between the two rotations).
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)
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();
206 /// This version of slerp, used by squad, does not check for theta > 90.
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)
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();
221 /// The spherical cubic interpolation.
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)
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();
238 /// Returns the shortest angle between two rotations in radians.
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)
246 float ret = Interop.Rotation.AngleBetween(Rotation.getCPtr(q1), Rotation.getCPtr(q2));
247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252 /// Helper to check if this is an identity quaternion.
254 /// <returns>True if this is identity quaternion.</returns>
255 /// <since_tizen> 3 </since_tizen>
256 public bool IsIdentity()
258 bool ret = Interop.Rotation.IsIdentity(SwigCPtr);
259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
264 /// Converts the quaternion to an axis or angle pair.
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)
272 bool ret = Interop.Rotation.GetAxisAngle(SwigCPtr, Vector3.getCPtr(axis), Radian.getCPtr(angle));
273 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
278 /// Returns the length of the rotation.
280 /// <returns>The length of the rotation.</returns>
281 /// <since_tizen> 3 </since_tizen>
282 public float Length()
284 float ret = Interop.Rotation.Length(SwigCPtr);
285 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290 /// Returns the squared length of the rotation.
292 /// <returns>The squared length of the rotation.</returns>
293 /// <since_tizen> 3 </since_tizen>
294 public float LengthSquared()
296 float ret = Interop.Rotation.LengthSquared(SwigCPtr);
297 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 /// Normalizes this to unit length.
304 /// <since_tizen> 3 </since_tizen>
305 public void Normalize()
307 Interop.Rotation.Normalize(SwigCPtr);
308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
314 /// <returns>A normalized version of this rotation.</returns>
315 /// <since_tizen> 3 </since_tizen>
316 public Rotation Normalized()
318 Rotation ret = new Rotation(Interop.Rotation.Normalized(SwigCPtr), true);
319 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
324 /// Conjugates this rotation.
326 /// <since_tizen> 3 </since_tizen>
327 public void Conjugate()
329 Interop.Rotation.Conjugate(SwigCPtr);
330 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334 /// Inverts this rotation.
336 /// <since_tizen> 3 </since_tizen>
339 Interop.Rotation.Invert(SwigCPtr);
340 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
344 /// Performs the logarithm of a rotation.
346 /// <returns>The rotation representing the logarithm.</returns>
347 /// <since_tizen> 3 </since_tizen>
348 public Rotation Log()
350 Rotation ret = new Rotation(Interop.Rotation.Log(SwigCPtr), true);
351 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
356 /// Performs an exponent.
358 /// <returns>The rotation representing the exponent.</returns>
359 /// <since_tizen> 3 </since_tizen>
360 public Rotation Exp()
362 Rotation ret = new Rotation(Interop.Rotation.Exp(SwigCPtr), true);
363 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
367 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Rotation obj)
369 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
372 internal Rotation(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
376 /// This will not be public opened.
377 [EditorBrowsable(EditorBrowsableState.Never)]
378 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
380 Interop.Rotation.DeleteRotation(swigCPtr);
383 private Rotation Add(Rotation other)
385 Rotation ret = new Rotation(Interop.Rotation.Add(SwigCPtr, Rotation.getCPtr(other)), true);
386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
390 private Rotation Subtract(Rotation other)
392 Rotation ret = new Rotation(Interop.Rotation.Subtract(SwigCPtr, Rotation.getCPtr(other)), true);
393 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
397 private Rotation Multiply(Rotation other)
399 Rotation ret = new Rotation(Interop.Rotation.MultiplyQuaternion(SwigCPtr, Rotation.getCPtr(other)), true);
400 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
404 private Vector3 Multiply(Vector3 other)
406 Vector3 ret = new Vector3(Interop.Rotation.MultiplyVector3(SwigCPtr, Vector3.getCPtr(other)), true);
407 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
411 private Rotation Divide(Rotation other)
413 Rotation ret = new Rotation(Interop.Rotation.Divide(SwigCPtr, Rotation.getCPtr(other)), true);
414 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418 private Rotation Multiply(float scale)
420 Rotation ret = new Rotation(Interop.Rotation.Multiply(SwigCPtr, scale), true);
421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
425 private Rotation Divide(float scale)
427 Rotation ret = new Rotation(Interop.Rotation.Divide(SwigCPtr, scale), true);
428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
432 private Rotation Subtract()
434 Rotation ret = new Rotation(Interop.Rotation.Subtract(SwigCPtr), true);
435 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
439 private Rotation AddAssign(Rotation other)
441 Rotation ret = new Rotation(Interop.Rotation.AddAssign(SwigCPtr, Rotation.getCPtr(other)), false);
442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
446 private Rotation SubtractAssign(Rotation other)
448 Rotation ret = new Rotation(Interop.Rotation.SubtractAssign(SwigCPtr, Rotation.getCPtr(other)), false);
449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
453 private Rotation MultiplyAssign(Rotation other)
455 Rotation ret = new Rotation(Interop.Rotation.MultiplyAssign(SwigCPtr, Rotation.getCPtr(other)), false);
456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
460 private Rotation MultiplyAssign(float scale)
462 Rotation ret = new Rotation(Interop.Rotation.MultiplyAssign(SwigCPtr, scale), false);
463 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
467 private Rotation DivideAssign(float scale)
469 Rotation ret = new Rotation(Interop.Rotation.DivideAssign(SwigCPtr, scale), false);
470 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
474 private bool EqualTo(Rotation rhs)
476 bool ret = Interop.Rotation.EqualTo(SwigCPtr, Rotation.getCPtr(rhs));
477 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
481 private bool NotEqualTo(Rotation rhs)
483 bool ret = Interop.Rotation.NotEqualTo(SwigCPtr, Rotation.getCPtr(rhs));
484 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();