/*
* Copyright(c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.ComponentModel;
using Tizen.NUI.Binding;
namespace Tizen.NUI
{
///
/// The Rotation class.
///
/// 3
[Binding.TypeConverter(typeof(RotationTypeConverter))]
public class Rotation : Disposable
{
///
/// The default constructor.
///
/// 3
public Rotation() : this(Interop.Rotation.NewRotation(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The constructor from an axis and angle.
///
/// The angle around the axis.
/// The vector of the axis.
/// 3
public Rotation(Radian angle, Vector3 axis) : this(Interop.Rotation.NewRotation(Radian.getCPtr(angle), Vector3.getCPtr(axis)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// (0.0f,0.0f,0.0f,1.0f).
///
/// 3
public static Rotation IDENTITY
{
get
{
global::System.IntPtr cPtr = Interop.Rotation.IdentityGet();
Rotation ret = (cPtr == global::System.IntPtr.Zero) ? null : new Rotation(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// The addition operator.
///
/// The first rotation.
/// The second rotation.
/// The rotation containing the result of the addition.
/// 3
public static Rotation operator +(Rotation arg1, Rotation arg2)
{
return arg1?.Add(arg2);
}
///
/// The subtraction operator.
///
/// The first rotation.
/// The second rotation.
/// The rotation containing the result of the subtraction.
/// 3
public static Rotation operator -(Rotation arg1, Rotation arg2)
{
return arg1?.Subtract(arg2);
}
///
/// The unary negation operator.
///
/// The first rotation.
/// The rotation containing the negated result.
/// 3
public static Rotation operator -(Rotation arg1)
{
return arg1?.Subtract();
}
///
/// The multiplication operator.
///
/// The first rotation.
/// The second rotation.
/// The rotation containing the result of the multiplication.
/// 3
public static Rotation operator *(Rotation arg1, Rotation arg2)
{
return arg1?.Multiply(arg2);
}
///
/// The multiplication operator.
///
/// Rotation.
/// The vector to multiply.
/// The rotation containing the result of the multiplication.
/// 3
public static Vector3 operator *(Rotation arg1, Vector3 arg2)
{
return arg1?.Multiply(arg2);
}
///
/// The scale operator.
///
/// Rotation.
/// A value to scale by.
/// The rotation containing the result of scaling.
/// 3
public static Rotation operator *(Rotation arg1, float arg2)
{
return arg1?.Multiply(arg2);
}
///
/// The division operator.
///
/// The first rotation.
/// The second rotation.
/// The rotation containing the result of scaling.
/// 3
public static Rotation operator /(Rotation arg1, Rotation arg2)
{
return arg1?.Divide(arg2);
}
///
/// The scale operator.
///
/// Rotation.
/// A value to scale by.
/// The rotation containing the result of scaling.
/// 3
public static Rotation operator /(Rotation arg1, float arg2)
{
return arg1?.Divide(arg2);
}
///
/// Returns the dot product of two rotations.
///
/// The first rotation.
/// The second rotation.
/// The dot product of the two rotations.
/// 3
public static float Dot(Rotation q1, Rotation q2)
{
float ret = Interop.Rotation.Dot(Rotation.getCPtr(q1), Rotation.getCPtr(q2));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// The linear iterpolation (using a straight line between the two rotations).
///
/// The start rotation.
/// The end rotation.
/// A progress value between 0 and 1.
/// The interpolated rotation.
/// 3
public static Rotation Lerp(Rotation q1, Rotation q2, float t)
{
Rotation ret = new Rotation(Interop.Rotation.Lerp(Rotation.getCPtr(q1), Rotation.getCPtr(q2), t), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// The spherical linear interpolation (using the shortest arc of a great circle between the two rotations).
///
/// The start rotation.
/// The end rotation.
/// A progress value between 0 and 1.
/// The interpolated rotation.
/// 3
public static Rotation Slerp(Rotation q1, Rotation q2, float progress)
{
Rotation ret = new Rotation(Interop.Rotation.Slerp(Rotation.getCPtr(q1), Rotation.getCPtr(q2), progress), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// This version of slerp, used by squad, does not check for theta > 90.
///
/// The start rotation.
/// The end rotation.
/// A progress value between 0 and 1.
/// The interpolated rotation.
/// 3
public static Rotation SlerpNoInvert(Rotation q1, Rotation q2, float t)
{
Rotation ret = new Rotation(Interop.Rotation.SlerpNoInvert(Rotation.getCPtr(q1), Rotation.getCPtr(q2), t), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// The spherical cubic interpolation.
///
/// The start rotation.
/// The end rotation.
/// The control rotation for q1.
/// The control rotation for q2.
/// A progress value between 0 and 1.
/// The interpolated rotation.
/// 3
public static Rotation Squad(Rotation start, Rotation end, Rotation ctrl1, Rotation ctrl2, float t)
{
Rotation ret = new Rotation(Interop.Rotation.Squad(Rotation.getCPtr(start), Rotation.getCPtr(end), Rotation.getCPtr(ctrl1), Rotation.getCPtr(ctrl2), t), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Returns the shortest angle between two rotations in radians.
///
/// The first rotation.
/// The second rotation.
/// The angle between the two rotation.
/// 3
public static float AngleBetween(Rotation q1, Rotation q2)
{
float ret = Interop.Rotation.AngleBetween(Rotation.getCPtr(q1), Rotation.getCPtr(q2));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Helper to check if this is an identity quaternion.
///
/// True if this is identity quaternion.
/// 3
public bool IsIdentity()
{
bool ret = Interop.Rotation.IsIdentity(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Converts the quaternion to an axis or angle pair.
///
/// The result of an an axis.
/// The result of angle in radians.
/// True if converted correctly.
/// 3
public bool GetAxisAngle(Vector3 axis, Radian angle)
{
bool ret = Interop.Rotation.GetAxisAngle(SwigCPtr, Vector3.getCPtr(axis), Radian.getCPtr(angle));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Returns the length of the rotation.
///
/// The length of the rotation.
/// 3
public float Length()
{
float ret = Interop.Rotation.Length(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Returns the squared length of the rotation.
///
/// The squared length of the rotation.
/// 3
public float LengthSquared()
{
float ret = Interop.Rotation.LengthSquared(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Normalizes this to unit length.
///
/// 3
public void Normalize()
{
Interop.Rotation.Normalize(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Normalized.
///
/// A normalized version of this rotation.
/// 3
public Rotation Normalized()
{
Rotation ret = new Rotation(Interop.Rotation.Normalized(SwigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Conjugates this rotation.
///
/// 3
public void Conjugate()
{
Interop.Rotation.Conjugate(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Inverts this rotation.
///
/// 3
public void Invert()
{
Interop.Rotation.Invert(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Performs the logarithm of a rotation.
///
/// The rotation representing the logarithm.
/// 3
public Rotation Log()
{
Rotation ret = new Rotation(Interop.Rotation.Log(SwigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Performs an exponent.
///
/// The rotation representing the exponent.
/// 3
public Rotation Exp()
{
Rotation ret = new Rotation(Interop.Rotation.Exp(SwigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Rotation obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
}
internal Rotation(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
{
}
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
Interop.Rotation.DeleteRotation(swigCPtr);
}
private Rotation Add(Rotation other)
{
Rotation ret = new Rotation(Interop.Rotation.Add(SwigCPtr, Rotation.getCPtr(other)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Rotation Subtract(Rotation other)
{
Rotation ret = new Rotation(Interop.Rotation.Subtract(SwigCPtr, Rotation.getCPtr(other)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Rotation Multiply(Rotation other)
{
Rotation ret = new Rotation(Interop.Rotation.MultiplyQuaternion(SwigCPtr, Rotation.getCPtr(other)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector3 Multiply(Vector3 other)
{
Vector3 ret = new Vector3(Interop.Rotation.MultiplyVector3(SwigCPtr, Vector3.getCPtr(other)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Rotation Divide(Rotation other)
{
Rotation ret = new Rotation(Interop.Rotation.Divide(SwigCPtr, Rotation.getCPtr(other)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Rotation Multiply(float scale)
{
Rotation ret = new Rotation(Interop.Rotation.Multiply(SwigCPtr, scale), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Rotation Divide(float scale)
{
Rotation ret = new Rotation(Interop.Rotation.Divide(SwigCPtr, scale), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Rotation Subtract()
{
Rotation ret = new Rotation(Interop.Rotation.Subtract(SwigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Rotation AddAssign(Rotation other)
{
Rotation ret = new Rotation(Interop.Rotation.AddAssign(SwigCPtr, Rotation.getCPtr(other)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Rotation SubtractAssign(Rotation other)
{
Rotation ret = new Rotation(Interop.Rotation.SubtractAssign(SwigCPtr, Rotation.getCPtr(other)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Rotation MultiplyAssign(Rotation other)
{
Rotation ret = new Rotation(Interop.Rotation.MultiplyAssign(SwigCPtr, Rotation.getCPtr(other)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Rotation MultiplyAssign(float scale)
{
Rotation ret = new Rotation(Interop.Rotation.MultiplyAssign(SwigCPtr, scale), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Rotation DivideAssign(float scale)
{
Rotation ret = new Rotation(Interop.Rotation.DivideAssign(SwigCPtr, scale), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private bool EqualTo(Rotation rhs)
{
bool ret = Interop.Rotation.EqualTo(SwigCPtr, Rotation.getCPtr(rhs));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private bool NotEqualTo(Rotation rhs)
{
bool ret = Interop.Rotation.NotEqualTo(SwigCPtr, Rotation.getCPtr(rhs));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
}