From e9b989e94ee082ff908c9987bca59f447b8e9882 Mon Sep 17 00:00:00 2001 From: seungho Date: Tue, 22 Jun 2021 09:44:50 +0900 Subject: [PATCH] [NUI] Add Rotate API in Rotation to rotate vector - NUI Rotation is based on Quaternion theoretically. - This patch adds Rotate method to rotate vector3 or vector4 with the quaternion. Signed-off-by: seungho --- .../src/internal/Interop/Interop.Rotation.cs | 6 +++++ src/Tizen.NUI/src/public/Common/Rotation.cs | 30 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.Rotation.cs b/src/Tizen.NUI/src/internal/Interop/Interop.Rotation.cs index 9938fb6..ee80e88 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.Rotation.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.Rotation.cs @@ -125,6 +125,12 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Rotation_AngleBetween")] public static extern float AngleBetween(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Rotation_Rotate_Vector3")] + public static extern global::System.IntPtr RotateVector3(global::System.Runtime.InteropServices.HandleRef nuiRotation, global::System.Runtime.InteropServices.HandleRef nuiVector3); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Rotation_Rotate_Vector4")] + public static extern global::System.IntPtr RotateVector4(global::System.Runtime.InteropServices.HandleRef nuiRotation, global::System.Runtime.InteropServices.HandleRef nuiVector4); } } } diff --git a/src/Tizen.NUI/src/public/Common/Rotation.cs b/src/Tizen.NUI/src/public/Common/Rotation.cs index a11447e..c42f150 100755 --- a/src/Tizen.NUI/src/public/Common/Rotation.cs +++ b/src/Tizen.NUI/src/public/Common/Rotation.cs @@ -249,6 +249,36 @@ namespace Tizen.NUI } /// + /// Rotate a vector3 with the Rotation. + /// For example, if this Rotation has (0, 1, 0) rotation axis and Math.PI radian angle and the input vector is (1, 0, 0), + /// this Rotation method returns (-1, 0, 0) that is rotated along Y axis amount of Math.PI. + /// + /// The vector of vector3 to be rotated with this Rotation + /// Vector3 that is the rotation result of this rotation. + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector3 Rotate(Vector3 vector) + { + Vector3 ret = new Vector3(Interop.Rotation.RotateVector3(SwigCPtr, Vector3.getCPtr(vector)), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Rotate a vector4 with the Rotation. + /// For example, if this Rotation has (0, 1, 0) rotation axis and Math.PI radian angle and the input vector is (1, 0, 0, 0), + /// this Rotation method returns (-1, 0, 0, 0) that is rotated along Y axis amount of Math.PI. + /// + /// The vector of vector4 to be rotated with this Rotation + /// Vector4 that is the rotation result of this rotation. + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector4 Rotate(Vector4 vector) + { + Vector4 ret = new Vector4(Interop.Rotation.RotateVector4(SwigCPtr, Vector4.getCPtr(vector)), true); + 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. -- 2.7.4